mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-11 15:56:17 -07:00
Fixed utf-8 support in paths and filenames
This commit is contained in:
parent
abb39d537c
commit
1bb286f4a9
9 changed files with 60 additions and 58 deletions
|
@ -5,6 +5,7 @@
|
||||||
- FEATURE: Allow user to change DHT port
|
- FEATURE: Allow user to change DHT port
|
||||||
- I18N: Added Finnish translation
|
- I18N: Added Finnish translation
|
||||||
- BUGFIX: Made right click menu work for multiple selection in DL list
|
- BUGFIX: Made right click menu work for multiple selection in DL list
|
||||||
|
- BUGFIX: Fixed utf-8 support in paths and filenames
|
||||||
- COSMETIC: Replaced OSD messages by systray messages
|
- COSMETIC: Replaced OSD messages by systray messages
|
||||||
- COSMETIC: Displaying save path in torrent properties window
|
- COSMETIC: Displaying save path in torrent properties window
|
||||||
- COSMETIC: Reworked options window a little
|
- COSMETIC: Reworked options window a little
|
||||||
|
|
66
src/GUI.cpp
66
src/GUI.cpp
|
@ -863,7 +863,7 @@ void GUI::saveColWidthDLList() const{
|
||||||
width_list << QString(misc::toString(downloadList->columnWidth(i)).c_str());
|
width_list << QString(misc::toString(downloadList->columnWidth(i)).c_str());
|
||||||
}
|
}
|
||||||
if(lastDLListWidth.open(QIODevice::WriteOnly | QIODevice::Text)){
|
if(lastDLListWidth.open(QIODevice::WriteOnly | QIODevice::Text)){
|
||||||
lastDLListWidth.write(QByteArray(width_list.join(" ").toStdString().c_str()));
|
lastDLListWidth.write(width_list.join(" ").toAscii());
|
||||||
lastDLListWidth.close();
|
lastDLListWidth.close();
|
||||||
qDebug("Columns width saved");
|
qDebug("Columns width saved");
|
||||||
}else{
|
}else{
|
||||||
|
@ -910,7 +910,7 @@ void GUI::saveColWidthSearchList() const{
|
||||||
width_list << QString(misc::toString(resultsBrowser->columnWidth(i)).c_str());
|
width_list << QString(misc::toString(resultsBrowser->columnWidth(i)).c_str());
|
||||||
}
|
}
|
||||||
if(lastSearchListWidth.open(QIODevice::WriteOnly | QIODevice::Text)){
|
if(lastSearchListWidth.open(QIODevice::WriteOnly | QIODevice::Text)){
|
||||||
lastSearchListWidth.write(QByteArray(width_list.join(" ").toStdString().c_str()));
|
lastSearchListWidth.write(width_list.join(" ").toAscii());
|
||||||
lastSearchListWidth.close();
|
lastSearchListWidth.close();
|
||||||
qDebug("Columns width saved in search list");
|
qDebug("Columns width saved in search list");
|
||||||
}else{
|
}else{
|
||||||
|
@ -1017,7 +1017,7 @@ void GUI::closeEvent(QCloseEvent *e){
|
||||||
if(DHTEnabled){
|
if(DHTEnabled){
|
||||||
try{
|
try{
|
||||||
entry dht_state = s->dht_state();
|
entry dht_state = s->dht_state();
|
||||||
boost::filesystem::ofstream out(misc::qBittorrentPath().toStdString()+"dht_state", std::ios_base::binary);
|
boost::filesystem::ofstream out((const char*)(misc::qBittorrentPath()+QString("dht_state")).toUtf8(), std::ios_base::binary);
|
||||||
out.unsetf(std::ios_base::skipws);
|
out.unsetf(std::ios_base::skipws);
|
||||||
bencode(std::ostream_iterator<char>(out), dht_state);
|
bencode(std::ostream_iterator<char>(out), dht_state);
|
||||||
}catch (std::exception& e){
|
}catch (std::exception& e){
|
||||||
|
@ -1114,7 +1114,7 @@ void GUI::askForTorrents(){
|
||||||
lastDirFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
lastDirFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
QStringList top_dir = pathsList.at(0).split(QDir::separator());
|
QStringList top_dir = pathsList.at(0).split(QDir::separator());
|
||||||
top_dir.removeLast();
|
top_dir.removeLast();
|
||||||
lastDirFile.write(QByteArray(top_dir.join(QDir::separator()).toStdString().c_str()));
|
lastDirFile.write(top_dir.join(QDir::separator()).toUtf8());
|
||||||
lastDirFile.close();
|
lastDirFile.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1150,7 +1150,7 @@ void GUI::scanDirectory(){
|
||||||
|
|
||||||
void GUI::saveFastResumeData() const{
|
void GUI::saveFastResumeData() const{
|
||||||
qDebug("Saving fast resume data");
|
qDebug("Saving fast resume data");
|
||||||
std::string file;
|
QString file;
|
||||||
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
|
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
|
||||||
// Checking if torrentBackup Dir exists
|
// Checking if torrentBackup Dir exists
|
||||||
// create it if it is not
|
// create it if it is not
|
||||||
|
@ -1163,14 +1163,14 @@ void GUI::saveFastResumeData() const{
|
||||||
h.pause();
|
h.pause();
|
||||||
// Extracting resume data
|
// Extracting resume data
|
||||||
if (h.has_metadata()){
|
if (h.has_metadata()){
|
||||||
QString filename = QString(h.get_torrent_info().name().c_str());
|
QString fileName = QString(h.get_torrent_info().name().c_str());
|
||||||
if(QFile::exists(torrentBackup.path()+QDir::separator()+filename+".torrent")){
|
if(QFile::exists(torrentBackup.path()+QDir::separator()+fileName+".torrent")){
|
||||||
// Remove old .fastresume data in case it exists
|
// Remove old .fastresume data in case it exists
|
||||||
QFile::remove(filename + ".fastresume");
|
QFile::remove(fileName + ".fastresume");
|
||||||
// Write fast resume data
|
// Write fast resume data
|
||||||
entry resumeData = h.write_resume_data();
|
entry resumeData = h.write_resume_data();
|
||||||
file = filename.toStdString() + ".fastresume";
|
file = fileName + ".fastresume";
|
||||||
boost::filesystem::ofstream out(fs::path(torrentBackup.path().toStdString()) / file, std::ios_base::binary);
|
boost::filesystem::ofstream out(fs::path((const char*)torrentBackup.path().toUtf8()) / (const char*)file.toUtf8(), std::ios_base::binary);
|
||||||
out.unsetf(std::ios_base::skipws);
|
out.unsetf(std::ios_base::skipws);
|
||||||
bencode(std::ostream_iterator<char>(out), resumeData);
|
bencode(std::ostream_iterator<char>(out), resumeData);
|
||||||
}
|
}
|
||||||
|
@ -1334,8 +1334,8 @@ void GUI::addTorrent(const QString& path, bool fromScanDir, const QString& from_
|
||||||
if(file.isEmpty()){
|
if(file.isEmpty()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug("Adding %s to download list", file.toStdString().c_str());
|
qDebug("Adding %s to download list", (const char*)file.toUtf8());
|
||||||
std::ifstream in(file.toStdString().c_str(), std::ios_base::binary);
|
std::ifstream in((const char*)file.toUtf8(), std::ios_base::binary);
|
||||||
in.unsetf(std::ios_base::skipws);
|
in.unsetf(std::ios_base::skipws);
|
||||||
try{
|
try{
|
||||||
// Decode torrent file
|
// Decode torrent file
|
||||||
|
@ -1363,7 +1363,7 @@ void GUI::addTorrent(const QString& path, bool fromScanDir, const QString& from_
|
||||||
try{
|
try{
|
||||||
std::stringstream strStream;
|
std::stringstream strStream;
|
||||||
strStream << t.name() << ".fastresume";
|
strStream << t.name() << ".fastresume";
|
||||||
boost::filesystem::ifstream resume_file(fs::path(torrentBackup.path().toStdString()) / strStream.str(), std::ios_base::binary);
|
boost::filesystem::ifstream resume_file(fs::path((const char*)torrentBackup.path().toUtf8()) / strStream.str(), std::ios_base::binary);
|
||||||
resume_file.unsetf(std::ios_base::skipws);
|
resume_file.unsetf(std::ios_base::skipws);
|
||||||
resume_data = bdecode(std::istream_iterator<char>(resume_file), std::istream_iterator<char>());
|
resume_data = bdecode(std::istream_iterator<char>(resume_file), std::istream_iterator<char>());
|
||||||
fastResume=true;
|
fastResume=true;
|
||||||
|
@ -1371,15 +1371,15 @@ void GUI::addTorrent(const QString& path, bool fromScanDir, const QString& from_
|
||||||
catch (fs::filesystem_error&) {}
|
catch (fs::filesystem_error&) {}
|
||||||
//qDebug("Got fast resume data");
|
//qDebug("Got fast resume data");
|
||||||
}
|
}
|
||||||
//Get Save Path TODO: finish
|
|
||||||
QString savePath = getSavePath(QString(t.name().c_str()));
|
QString savePath = getSavePath(QString(t.name().c_str()));
|
||||||
int row = DLListModel->rowCount();
|
int row = DLListModel->rowCount();
|
||||||
// Adding files to bittorrent session
|
// Adding files to bittorrent session
|
||||||
|
std::cout << "save path: " << (const char*)savePath.toUtf8() << "\n";
|
||||||
if(hasFilteredFiles(QString(t.name().c_str()))){
|
if(hasFilteredFiles(QString(t.name().c_str()))){
|
||||||
h = s->add_torrent(t, fs::path(savePath.toStdString()), resume_data, false);
|
h = s->add_torrent(t, fs::path((const char*)savePath.toUtf8()), resume_data, false);
|
||||||
qDebug("Full allocation mode");
|
qDebug("Full allocation mode");
|
||||||
}else{
|
}else{
|
||||||
h = s->add_torrent(t, fs::path(savePath.toStdString()), resume_data, true);
|
h = s->add_torrent(t, fs::path((const char*)savePath.toUtf8()), resume_data, true);
|
||||||
qDebug("Compact allocation mode");
|
qDebug("Compact allocation mode");
|
||||||
}
|
}
|
||||||
h.set_max_connections(60);
|
h.set_max_connections(60);
|
||||||
|
@ -1496,7 +1496,7 @@ QString GUI::getSavePath(QString fileName){
|
||||||
line = savepath_file.readAll();
|
line = savepath_file.readAll();
|
||||||
savepath_file.close();
|
savepath_file.close();
|
||||||
qDebug("Save path: %s", line.data());
|
qDebug("Save path: %s", line.data());
|
||||||
savePath = QString(line.data());
|
savePath = QString::fromUtf8(line.data());
|
||||||
}else{
|
}else{
|
||||||
savePath = options->getSavePath();
|
savePath = options->getSavePath();
|
||||||
}
|
}
|
||||||
|
@ -1505,7 +1505,7 @@ QString GUI::getSavePath(QString fileName){
|
||||||
QDir saveDir(savePath);
|
QDir saveDir(savePath);
|
||||||
if(!saveDir.exists()){
|
if(!saveDir.exists()){
|
||||||
if(!saveDir.mkpath(saveDir.path())){
|
if(!saveDir.mkpath(saveDir.path())){
|
||||||
std::cerr << "Couldn't create the save directory: " << saveDir.path().toStdString() +"\n";
|
std::cerr << "Couldn't create the save directory: " << (const char*)saveDir.path().toUtf8() << "\n";
|
||||||
// TODO: handle this better
|
// TODO: handle this better
|
||||||
return QDir::homePath();
|
return QDir::homePath();
|
||||||
}
|
}
|
||||||
|
@ -1516,7 +1516,7 @@ QString GUI::getSavePath(QString fileName){
|
||||||
void GUI::reloadTorrent(const torrent_handle &h, bool compact_mode){
|
void GUI::reloadTorrent(const torrent_handle &h, bool compact_mode){
|
||||||
QDir saveDir(options->getSavePath()), torrentBackup(misc::qBittorrentPath() + "BT_backup");
|
QDir saveDir(options->getSavePath()), torrentBackup(misc::qBittorrentPath() + "BT_backup");
|
||||||
QString fileName = QString(h.get_torrent_info().name().c_str());
|
QString fileName = QString(h.get_torrent_info().name().c_str());
|
||||||
qDebug("Reloading torrent: %s", fileName.toStdString().c_str());
|
qDebug("Reloading torrent: %s", (const char*)fileName.toUtf8());
|
||||||
torrent_handle new_h;
|
torrent_handle new_h;
|
||||||
entry resumeData;
|
entry resumeData;
|
||||||
torrent_info t = h.get_torrent_info();
|
torrent_info t = h.get_torrent_info();
|
||||||
|
@ -1556,7 +1556,7 @@ void GUI::reloadTorrent(const torrent_handle &h, bool compact_mode){
|
||||||
std::cerr << "Error: Couldn't reload the torrent\n";
|
std::cerr << "Error: Couldn't reload the torrent\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new_h = s->add_torrent(t, fs::path(saveDir.path().toStdString()), resumeData, compact_mode);
|
new_h = s->add_torrent(t, fs::path((const char*)saveDir.path().toUtf8()), resumeData, compact_mode);
|
||||||
if(compact_mode){
|
if(compact_mode){
|
||||||
qDebug("Using compact allocation mode");
|
qDebug("Using compact allocation mode");
|
||||||
}else{
|
}else{
|
||||||
|
@ -1590,7 +1590,7 @@ void GUI::reloadTorrent(const torrent_handle &h, bool compact_mode){
|
||||||
}
|
}
|
||||||
// Incremental download
|
// Incremental download
|
||||||
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".incremental")){
|
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".incremental")){
|
||||||
qDebug("Incremental download enabled for %s", fileName.toStdString().c_str());
|
qDebug("Incremental download enabled for %s", (const char*)fileName.toUtf8());
|
||||||
new_h.set_sequenced_download_threshold(15);
|
new_h.set_sequenced_download_threshold(15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1686,7 +1686,7 @@ void GUI::configureSession(){
|
||||||
setGlobalRatio(options->getRatio());
|
setGlobalRatio(options->getRatio());
|
||||||
// DHT (Trackerless)
|
// DHT (Trackerless)
|
||||||
if(options->isDHTEnabled() && !DHTEnabled){
|
if(options->isDHTEnabled() && !DHTEnabled){
|
||||||
boost::filesystem::ifstream dht_state_file(misc::qBittorrentPath().toStdString()+"dht_state", std::ios_base::binary);
|
boost::filesystem::ifstream dht_state_file((const char*)(misc::qBittorrentPath()+QString("dht_state")).toUtf8(), std::ios_base::binary);
|
||||||
dht_state_file.unsetf(std::ios_base::skipws);
|
dht_state_file.unsetf(std::ios_base::skipws);
|
||||||
entry dht_state;
|
entry dht_state;
|
||||||
try{
|
try{
|
||||||
|
@ -2156,15 +2156,15 @@ void GUI::updateNova() const{
|
||||||
// ask user for action.
|
// ask user for action.
|
||||||
void GUI::on_update_nova_button_clicked(){
|
void GUI::on_update_nova_button_clicked(){
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
std::string filePath;
|
QString filePath;
|
||||||
qDebug("Checking for search plugin updates on qbittorrent.org");
|
qDebug("Checking for search plugin updates on qbittorrent.org");
|
||||||
// XXX: Trick to get a unique filename
|
// XXX: Trick to get a unique filename
|
||||||
QTemporaryFile *tmpfile = new QTemporaryFile;
|
QTemporaryFile *tmpfile = new QTemporaryFile;
|
||||||
if (tmpfile->open()) {
|
if (tmpfile->open()) {
|
||||||
filePath = tmpfile->fileName().toStdString();
|
filePath = tmpfile->fileName();
|
||||||
}
|
}
|
||||||
delete tmpfile;
|
delete tmpfile;
|
||||||
FILE *file = fopen(filePath.c_str(), "w");
|
FILE *file = fopen((const char*)filePath.toUtf8(), "w");
|
||||||
if(!file){
|
if(!file){
|
||||||
std::cerr << "Error: could not open temporary file...\n";
|
std::cerr << "Error: could not open temporary file...\n";
|
||||||
}
|
}
|
||||||
|
@ -2190,12 +2190,12 @@ void GUI::on_update_nova_button_clicked(){
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
// Close tmp file
|
// Close tmp file
|
||||||
fclose(file);
|
fclose(file);
|
||||||
qDebug("Version on qbittorrent.org: %f", getNovaVersion(QString(filePath.c_str())));
|
qDebug("Version on qbittorrent.org: %f", getNovaVersion(filePath));
|
||||||
float version_on_server = getNovaVersion(QString(filePath.c_str()));
|
float version_on_server = getNovaVersion(filePath);
|
||||||
if(version_on_server == 0.0){
|
if(version_on_server == 0.0){
|
||||||
//First server is down, try mirror
|
//First server is down, try mirror
|
||||||
QFile::remove(filePath.c_str());
|
QFile::remove(filePath);
|
||||||
FILE *file = fopen(filePath.c_str(), "w");
|
FILE *file = fopen((const char*)filePath.toUtf8(), "w");
|
||||||
if(!file){
|
if(!file){
|
||||||
std::cerr << "Error: could not open temporary file...\n";
|
std::cerr << "Error: could not open temporary file...\n";
|
||||||
}
|
}
|
||||||
|
@ -2214,19 +2214,19 @@ void GUI::on_update_nova_button_clicked(){
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
// Close tmp file
|
// Close tmp file
|
||||||
fclose(file);
|
fclose(file);
|
||||||
version_on_server = getNovaVersion(QString(filePath.c_str()));
|
version_on_server = getNovaVersion(filePath);
|
||||||
}
|
}
|
||||||
if(version_on_server > getNovaVersion(misc::qBittorrentPath()+"nova.py")){
|
if(version_on_server > getNovaVersion(misc::qBittorrentPath()+"nova.py")){
|
||||||
if(QMessageBox::question(this,
|
if(QMessageBox::question(this,
|
||||||
tr("Search plugin update -- qBittorrent"),
|
tr("Search plugin update -- qBittorrent"),
|
||||||
tr("Search plugin can be updated, do you want to update it?\n\nChangelog:\n")+QString(getNovaChangelog(QString(filePath.c_str())).data()),
|
tr("Search plugin can be updated, do you want to update it?\n\nChangelog:\n")+getNovaChangelog(filePath),
|
||||||
tr("&Yes"), tr("&No"),
|
tr("&Yes"), tr("&No"),
|
||||||
QString(), 0, 1)){
|
QString(), 0, 1)){
|
||||||
return;
|
return;
|
||||||
}else{
|
}else{
|
||||||
qDebug("Updating search plugin from qbittorrent.org");
|
qDebug("Updating search plugin from qbittorrent.org");
|
||||||
QFile::remove(misc::qBittorrentPath()+"nova.py");
|
QFile::remove(misc::qBittorrentPath()+"nova.py");
|
||||||
QFile::copy(QString(filePath.c_str()), misc::qBittorrentPath()+"nova.py");
|
QFile::copy(filePath, misc::qBittorrentPath()+"nova.py");
|
||||||
QFile::Permissions perm=QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner | QFile::ReadUser | QFile::WriteUser | QFile::ExeUser | QFile::ReadGroup | QFile::ReadGroup;
|
QFile::Permissions perm=QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner | QFile::ReadUser | QFile::WriteUser | QFile::ExeUser | QFile::ReadGroup | QFile::ReadGroup;
|
||||||
QFile(misc::qBittorrentPath()+"nova.py").setPermissions(perm);
|
QFile(misc::qBittorrentPath()+"nova.py").setPermissions(perm);
|
||||||
}
|
}
|
||||||
|
@ -2240,7 +2240,7 @@ void GUI::on_update_nova_button_clicked(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Delete tmp file
|
// Delete tmp file
|
||||||
QFile::remove(filePath.c_str());
|
QFile::remove(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slot called when search is Finished
|
// Slot called when search is Finished
|
||||||
|
|
|
@ -99,8 +99,8 @@ void createtorrent::on_createButton_clicked(){
|
||||||
int piece_size = 256 * 1024;
|
int piece_size = 256 * 1024;
|
||||||
try {
|
try {
|
||||||
torrent_info t;
|
torrent_info t;
|
||||||
path full_path = complete(path(input.toStdString().c_str()));
|
path full_path = complete(path((const char*)input.toUtf8()));
|
||||||
ofstream out(complete(path(destination.toStdString().c_str())), std::ios_base::binary);
|
ofstream out(complete(path((const char*)destination.toUtf8())), std::ios_base::binary);
|
||||||
|
|
||||||
add_files(t, full_path.branch_path(), full_path.leaf());
|
add_files(t, full_path.branch_path(), full_path.leaf());
|
||||||
t.set_piece_size(piece_size);
|
t.set_piece_size(piece_size);
|
||||||
|
@ -108,7 +108,7 @@ void createtorrent::on_createButton_clicked(){
|
||||||
storage st(t, full_path.branch_path());
|
storage st(t, full_path.branch_path());
|
||||||
QStringList trackers = txt_announce->toPlainText().split('\n');
|
QStringList trackers = txt_announce->toPlainText().split('\n');
|
||||||
for(int i=0; i<trackers.size(); ++i){
|
for(int i=0; i<trackers.size(); ++i){
|
||||||
t.add_tracker(trackers.at(i).toStdString().c_str());
|
t.add_tracker((const char*)trackers.at(i).toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate the hash for all pieces
|
// calculate the hash for all pieces
|
||||||
|
@ -123,7 +123,7 @@ void createtorrent::on_createButton_clicked(){
|
||||||
// Set qBittorrent as creator and add user comment to
|
// Set qBittorrent as creator and add user comment to
|
||||||
// torrent_info structure
|
// torrent_info structure
|
||||||
t.set_creator(creator_str);
|
t.set_creator(creator_str);
|
||||||
t.set_comment(txt_comment->toPlainText().toStdString().c_str());
|
t.set_comment((const char*)txt_comment->toPlainText().toUtf8());
|
||||||
// create the torrent and print it to out
|
// create the torrent and print it to out
|
||||||
entry e = t.create_torrent();
|
entry e = t.create_torrent();
|
||||||
libtorrent::bencode(std::ostream_iterator<char>(out), e);
|
libtorrent::bencode(std::ostream_iterator<char>(out), e);
|
||||||
|
|
|
@ -68,15 +68,15 @@ class downloadThread : public QThread {
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
qDebug("In Download thread RUN, mutex unlocked (got url)");
|
qDebug("In Download thread RUN, mutex unlocked (got url)");
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
std::string filePath;
|
QString filePath;
|
||||||
int return_code, response;
|
int return_code, response;
|
||||||
// XXX: Trick to get a unique filename
|
// XXX: Trick to get a unique filename
|
||||||
QTemporaryFile *tmpfile = new QTemporaryFile;
|
QTemporaryFile *tmpfile = new QTemporaryFile;
|
||||||
if (tmpfile->open()) {
|
if (tmpfile->open()) {
|
||||||
filePath = tmpfile->fileName().toStdString();
|
filePath = tmpfile->fileName();
|
||||||
}
|
}
|
||||||
delete tmpfile;
|
delete tmpfile;
|
||||||
FILE *file = fopen(filePath.c_str(), "w");
|
FILE *file = fopen((const char*)filePath.toUtf8(), "w");
|
||||||
if(!file){
|
if(!file){
|
||||||
std::cerr << "Error: could not open temporary file...\n";
|
std::cerr << "Error: could not open temporary file...\n";
|
||||||
return;
|
return;
|
||||||
|
@ -88,10 +88,9 @@ class downloadThread : public QThread {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string urlString = url.toStdString();
|
|
||||||
// Set url to download
|
// Set url to download
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, urlString.c_str());
|
curl_easy_setopt(curl, CURLOPT_URL, (const char*)url.toUtf8());
|
||||||
qDebug("Url: %s", urlString.c_str());
|
qDebug("Url: %s", (const char*)url.toUtf8());
|
||||||
// Define our callback to get called when there's data to be written
|
// Define our callback to get called when there's data to be written
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, misc::my_fwrite);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, misc::my_fwrite);
|
||||||
// Set destination file
|
// Set destination file
|
||||||
|
@ -116,7 +115,7 @@ class downloadThread : public QThread {
|
||||||
if(return_code){
|
if(return_code){
|
||||||
std::cerr << "Error: failed to set error buffer in curl\n";
|
std::cerr << "Error: failed to set error buffer in curl\n";
|
||||||
fclose(file);
|
fclose(file);
|
||||||
QFile::remove(filePath.c_str());
|
QFile::remove(filePath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
unsigned short retries = 0;
|
unsigned short retries = 0;
|
||||||
|
@ -137,7 +136,7 @@ class downloadThread : public QThread {
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
// Close tmp file
|
// Close tmp file
|
||||||
fclose(file);
|
fclose(file);
|
||||||
emit downloadFinished(url, QString(filePath.c_str()), return_code, QString(errorBuffer));
|
emit downloadFinished(url, filePath, return_code, QString(errorBuffer));
|
||||||
qDebug("In Download thread RUN, signal emitted, ErrorBuffer: %s", errorBuffer);
|
qDebug("In Download thread RUN, signal emitted, ErrorBuffer: %s", errorBuffer);
|
||||||
}else{
|
}else{
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
|
@ -124,7 +124,7 @@ int main(int argc, char *argv[]){
|
||||||
bool isLocalized = false;
|
bool isLocalized = false;
|
||||||
// Open options file to read locale
|
// Open options file to read locale
|
||||||
QString optionsPath = misc::qBittorrentPath()+"options.xml";
|
QString optionsPath = misc::qBittorrentPath()+"options.xml";
|
||||||
FILE *f = fopen(optionsPath.toStdString().c_str(), "r");
|
FILE *f = fopen((const char*)optionsPath.toUtf8(), "r");
|
||||||
if(f){
|
if(f){
|
||||||
if (file.open(f, QIODevice::ReadOnly | QIODevice::Text)){
|
if (file.open(f, QIODevice::ReadOnly | QIODevice::Text)){
|
||||||
if (doc.setContent(&file)) {
|
if (doc.setContent(&file)) {
|
||||||
|
@ -145,9 +145,9 @@ int main(int argc, char *argv[]){
|
||||||
locale = QLocale::system().name();
|
locale = QLocale::system().name();
|
||||||
}
|
}
|
||||||
if(translator.load(QString(":/lang/qbittorrent_") + locale)){
|
if(translator.load(QString(":/lang/qbittorrent_") + locale)){
|
||||||
qDebug("%s locale recognized, using translation.", locale.toStdString().c_str());
|
qDebug("%s locale recognized, using translation.", (const char*)locale.toUtf8());
|
||||||
}else{
|
}else{
|
||||||
qDebug("%s locale unrecognized, using default (en_GB).", locale.toStdString().c_str());
|
qDebug("%s locale unrecognized, using default (en_GB).", (const char*)locale.toUtf8());
|
||||||
}
|
}
|
||||||
app.installTranslator(&translator);
|
app.installTranslator(&translator);
|
||||||
// Read torrents given on command line
|
// Read torrents given on command line
|
||||||
|
|
|
@ -324,19 +324,19 @@ bool options_imp::saveOptions(){
|
||||||
tag.appendChild(optionValue);
|
tag.appendChild(optionValue);
|
||||||
xml = doc.toString();
|
xml = doc.toString();
|
||||||
// Write XML file to HD
|
// Write XML file to HD
|
||||||
f = fopen(savePath.toStdString().c_str(), "w");
|
f = fopen((const char*)savePath.toUtf8(), "w");
|
||||||
if (!f){
|
if (!f){
|
||||||
std::cerr << "Error: Couldn't create file " << savePath.toStdString() << " for saving!" << '\n';
|
std::cerr << "Error: Couldn't create file " << (const char*)savePath.toUtf8() << " for saving!" << '\n';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!file.open(f, QIODevice::WriteOnly | QIODevice::Text)){
|
if (!file.open(f, QIODevice::WriteOnly | QIODevice::Text)){
|
||||||
std::cerr << "Error: Couldn't open file " << savePath.toStdString() << " for saving!" << '\n';
|
std::cerr << "Error: Couldn't open file " << (const char*)savePath.toUtf8() << " for saving!" << '\n';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
file.write(xml.toStdString().c_str(), xml.length());
|
file.write((const char*)xml.toUtf8(), xml.length());
|
||||||
file.close();
|
file.close();
|
||||||
if(fclose(f) == EOF){
|
if(fclose(f) == EOF){
|
||||||
std::cerr << "Error: Couldn't close file " << savePath.toStdString() << " after saving!" << '\n';
|
std::cerr << "Error: Couldn't close file " << (const char*)savePath.toUtf8() << " after saving!" << '\n';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// set infobar text
|
// set infobar text
|
||||||
|
@ -365,7 +365,7 @@ bool options_imp::loadOptions(){
|
||||||
// Getting savepath for options.xml
|
// Getting savepath for options.xml
|
||||||
savePath = misc::qBittorrentPath() + "options.xml";
|
savePath = misc::qBittorrentPath() + "options.xml";
|
||||||
// Read XML file on HD
|
// Read XML file on HD
|
||||||
f = fopen(savePath.toStdString().c_str(), "r");
|
f = fopen((const char*)savePath.toUtf8(), "r");
|
||||||
if (!f){
|
if (!f){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,7 @@ bool options_imp::loadOptions(){
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
if(fclose(f) == EOF){
|
if(fclose(f) == EOF){
|
||||||
std::cerr << "Error: Couldn't close file " << savePath.toStdString() << " after reading!" << '\n';
|
std::cerr << "Error: Couldn't close file " << (const char*)savePath.toUtf8() << " after reading!" << '\n';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Loading option from XML
|
// Loading option from XML
|
||||||
|
|
|
@ -29,6 +29,8 @@ CONFIG += link_pkgconfig
|
||||||
PKGCONFIG += libtorrent
|
PKGCONFIG += libtorrent
|
||||||
QT += xml network
|
QT += xml network
|
||||||
|
|
||||||
|
DEFINES += QT_NO_CAST_TO_ASCII
|
||||||
|
|
||||||
contains(DEBUG_MODE, 0){
|
contains(DEBUG_MODE, 0){
|
||||||
contains(QT_VERSION, 4.2.0) {
|
contains(QT_VERSION, 4.2.0) {
|
||||||
message(Qt 4.2.0 detected : enabling debug output because of a bug in this version of Qt)
|
message(Qt 4.2.0 detected : enabling debug output because of a bug in this version of Qt)
|
||||||
|
|
|
@ -65,7 +65,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
||||||
home += QDir::separator();
|
home += QDir::separator();
|
||||||
}
|
}
|
||||||
savePathTxt->setText(home+"qBT_dir");
|
savePathTxt->setText(home+"qBT_dir");
|
||||||
std::ifstream in(filePath.toStdString().c_str(), std::ios_base::binary);
|
std::ifstream in((const char*)filePath.toUtf8(), std::ios_base::binary);
|
||||||
in.unsetf(std::ios_base::skipws);
|
in.unsetf(std::ios_base::skipws);
|
||||||
try{
|
try{
|
||||||
// Decode torrent file
|
// Decode torrent file
|
||||||
|
@ -204,7 +204,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
||||||
// Save savepath
|
// Save savepath
|
||||||
QFile savepath_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".savepath");
|
QFile savepath_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".savepath");
|
||||||
savepath_file.open(QIODevice::WriteOnly | QIODevice::Text);
|
savepath_file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
savepath_file.write(QByteArray(savePath.path().toStdString().c_str()));
|
savepath_file.write(savePath.path().toUtf8());
|
||||||
savepath_file.close();
|
savepath_file.close();
|
||||||
// Create .incremental file if necessary
|
// Create .incremental file if necessary
|
||||||
if(checkIncrementalDL->isChecked()){
|
if(checkIncrementalDL->isChecked()){
|
||||||
|
|
|
@ -54,7 +54,7 @@ class trackerLogin : public QDialog, private Ui::authentication{
|
||||||
public slots:
|
public slots:
|
||||||
void on_loginButton_clicked(){
|
void on_loginButton_clicked(){
|
||||||
// login
|
// login
|
||||||
h.set_tracker_login(lineUsername->text().toStdString(), linePasswd->text().toStdString());
|
h.set_tracker_login(std::string((const char*)lineUsername->text().toUtf8()), std::string((const char*)linePasswd->text().toUtf8()));
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue