mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
- display errors in stderr instead of stdout
This commit is contained in:
parent
48663205b7
commit
a2c5afcf7c
52
src/GUI.cpp
52
src/GUI.cpp
@ -179,7 +179,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
|
|||||||
// Use a tcp server to allow only one instance of qBittorrent
|
// Use a tcp server to allow only one instance of qBittorrent
|
||||||
tcpServer = new QTcpServer(this);
|
tcpServer = new QTcpServer(this);
|
||||||
if (!tcpServer->listen(QHostAddress::LocalHost, 1666)) {
|
if (!tcpServer->listen(QHostAddress::LocalHost, 1666)) {
|
||||||
std::cout << "Couldn't create socket, single instance mode won't work...\n";
|
std::cerr << "Couldn't create socket, single instance mode won't work...\n";
|
||||||
}
|
}
|
||||||
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(AnotherInstanceConnected()));
|
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(AnotherInstanceConnected()));
|
||||||
// Start connection checking timer
|
// Start connection checking timer
|
||||||
@ -427,7 +427,7 @@ void GUI::readParamsInFile(){
|
|||||||
params << line;
|
params << line;
|
||||||
}
|
}
|
||||||
if(params.size()){
|
if(params.size()){
|
||||||
std::cout << "Received parameters from another instance\n";
|
qDebug("Received parameters from another instance");
|
||||||
addTorrents(params);
|
addTorrents(params);
|
||||||
}
|
}
|
||||||
paramsFile.close();
|
paramsFile.close();
|
||||||
@ -470,7 +470,7 @@ void GUI::updateDlList(){
|
|||||||
if(!h.is_paused()){
|
if(!h.is_paused()){
|
||||||
int row = getRowFromName(fileName);
|
int row = getRowFromName(fileName);
|
||||||
if(row == -1){
|
if(row == -1){
|
||||||
std::cout << "Error: Could not find filename in download list..\n";
|
std::cerr << "Error: Could not find filename in download list..\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Parse download state
|
// Parse download state
|
||||||
@ -721,7 +721,7 @@ void GUI::saveWindowSize() const{
|
|||||||
lastWindowSize.close();
|
lastWindowSize.close();
|
||||||
qDebug("Saved window size");
|
qDebug("Saved window size");
|
||||||
}else{
|
}else{
|
||||||
std::cout << "Error: Could not save last windows size\n";
|
std::cerr << "Error: Could not save last windows size\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,7 +738,7 @@ bool GUI::loadFilteredFiles(torrent_handle &h){
|
|||||||
pieces_file.close();
|
pieces_file.close();
|
||||||
QList<QByteArray> pieces_selection_list = pieces_selection.split('\n');
|
QList<QByteArray> pieces_selection_list = pieces_selection.split('\n');
|
||||||
if(pieces_selection_list.size() != torrentInfo.num_files()+1){
|
if(pieces_selection_list.size() != torrentInfo.num_files()+1){
|
||||||
std::cout << "Error: Corrupted pieces file\n";
|
std::cerr << "Error: Corrupted pieces file\n";
|
||||||
return has_filtered_files;
|
return has_filtered_files;
|
||||||
}
|
}
|
||||||
std::vector<bool> selectionBitmask;
|
std::vector<bool> selectionBitmask;
|
||||||
@ -831,7 +831,7 @@ void GUI::saveCheckedSearchEngines(int) const{
|
|||||||
lastSearchEngines.close();
|
lastSearchEngines.close();
|
||||||
qDebug("Saved checked search engines");
|
qDebug("Saved checked search engines");
|
||||||
}else{
|
}else{
|
||||||
std::cout << "Error: Could not save last checked search engines\n";
|
std::cerr << "Error: Could not save last checked search engines\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -851,7 +851,7 @@ void GUI::saveColWidthDLList() const{
|
|||||||
lastDLListWidth.close();
|
lastDLListWidth.close();
|
||||||
qDebug("Columns width saved");
|
qDebug("Columns width saved");
|
||||||
}else{
|
}else{
|
||||||
std::cout << "Error: Could not save last columns width in download list\n";
|
std::cerr << "Error: Could not save last columns width in download list\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -875,7 +875,7 @@ bool GUI::loadColWidthDLList(){
|
|||||||
qDebug("Loaded columns width in download list");
|
qDebug("Loaded columns width in download list");
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
std::cout << "Error: Could not load last columns width for download list\n";
|
std::cerr << "Error: Could not load last columns width for download list\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -898,7 +898,7 @@ void GUI::saveColWidthSearchList() const{
|
|||||||
lastSearchListWidth.close();
|
lastSearchListWidth.close();
|
||||||
qDebug("Columns width saved in search list");
|
qDebug("Columns width saved in search list");
|
||||||
}else{
|
}else{
|
||||||
std::cout << "Error: Could not save last columns width in search results list\n";
|
std::cerr << "Error: Could not save last columns width in search results list\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -922,7 +922,7 @@ bool GUI::loadColWidthSearchList(){
|
|||||||
qDebug("Columns width loaded in search list");
|
qDebug("Columns width loaded in search list");
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
std::cout << "Error: Could not load last columns width for search results list\n";
|
std::cerr << "Error: Could not load last columns width for search results list\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -974,7 +974,7 @@ void GUI::loadCheckedSearchEngines(){
|
|||||||
}
|
}
|
||||||
qDebug("Checked search engines loaded");
|
qDebug("Checked search engines loaded");
|
||||||
}else{
|
}else{
|
||||||
std::cout << "Error: Could not load last checked search engines\n";
|
std::cerr << "Error: Could not load last checked search engines\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1005,7 +1005,7 @@ void GUI::closeEvent(QCloseEvent *e){
|
|||||||
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){
|
||||||
std::cout << e.what() << "\n";
|
std::cerr << e.what() << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Save window size, columns size
|
// Save window size, columns size
|
||||||
@ -1242,7 +1242,7 @@ void GUI::deleteSelection(){
|
|||||||
--nbTorrents;
|
--nbTorrents;
|
||||||
tabs->setTabText(0, tr("Transfers") +" ("+QString(misc::toString(nbTorrents).c_str())+")");
|
tabs->setTabText(0, tr("Transfers") +" ("+QString(misc::toString(nbTorrents).c_str())+")");
|
||||||
}else{
|
}else{
|
||||||
std::cout << "Error: Could not find the torrent handle supposed to be removed\n";
|
std::cerr << "Error: Could not find the torrent handle supposed to be removed\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1417,7 +1417,7 @@ void GUI::addTorrents(const QStringList& pathsList, bool fromScanDir, const QStr
|
|||||||
++nbTorrents;
|
++nbTorrents;
|
||||||
tabs->setTabText(0, tr("Transfers") +" ("+QString(misc::toString(nbTorrents).c_str())+")");
|
tabs->setTabText(0, tr("Transfers") +" ("+QString(misc::toString(nbTorrents).c_str())+")");
|
||||||
}catch (invalid_encoding& e){ // Raised by bdecode()
|
}catch (invalid_encoding& e){ // Raised by bdecode()
|
||||||
std::cout << "Could not decode file, reason: " << e.what() << '\n';
|
std::cerr << "Could not decode file, reason: " << e.what() << '\n';
|
||||||
// Display warning to tell user we can't decode the torrent file
|
// Display warning to tell user we can't decode the torrent file
|
||||||
if(!from_url.isNull()){
|
if(!from_url.isNull()){
|
||||||
setInfoBar(tr("Unable to decode torrent file:")+" '"+from_url+"'", "red");
|
setInfoBar(tr("Unable to decode torrent file:")+" '"+from_url+"'", "red");
|
||||||
@ -1488,7 +1488,7 @@ void GUI::reloadTorrent(const torrent_handle &h, bool compact_mode){
|
|||||||
++timeout;
|
++timeout;
|
||||||
}
|
}
|
||||||
if(h.is_valid()){
|
if(h.is_valid()){
|
||||||
std::cout << "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(saveDir.path().toStdString()), resumeData, compact_mode);
|
||||||
@ -1666,7 +1666,7 @@ void GUI::configureSession(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(std::exception& e){
|
}catch(std::exception& e){
|
||||||
std::cout << e.what() << "\n";
|
std::cerr << e.what() << "\n";
|
||||||
}
|
}
|
||||||
qDebug("Session configured");
|
qDebug("Session configured");
|
||||||
}
|
}
|
||||||
@ -1688,7 +1688,7 @@ void GUI::pauseAll(){
|
|||||||
// update DL Status
|
// update DL Status
|
||||||
int row = getRowFromName(fileName);
|
int row = getRowFromName(fileName);
|
||||||
if(row == -1){
|
if(row == -1){
|
||||||
std::cout << "Error: Filename could not be found in download list...\n";
|
std::cerr << "Error: Filename could not be found in download list...\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.));
|
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.));
|
||||||
@ -1750,7 +1750,7 @@ void GUI::startAll(){
|
|||||||
// update DL Status
|
// update DL Status
|
||||||
int row = getRowFromName(fileName);
|
int row = getRowFromName(fileName);
|
||||||
if(row == -1){
|
if(row == -1){
|
||||||
std::cout << "Error: Filename could not be found in download list...\n";
|
std::cerr << "Error: Filename could not be found in download list...\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting...")));
|
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting...")));
|
||||||
@ -2062,7 +2062,7 @@ void GUI::updateNova() const{
|
|||||||
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);
|
||||||
if(provided_nova_version > getNovaVersion(misc::qBittorrentPath()+"nova.py")){
|
if(provided_nova_version > getNovaVersion(misc::qBittorrentPath()+"nova.py")){
|
||||||
std::cout << "updating local search plugin with shipped one\n";
|
qDebug("updating local search plugin with shipped one");
|
||||||
// nova.py needs update
|
// nova.py needs update
|
||||||
QFile::remove(misc::qBittorrentPath()+"nova.py");
|
QFile::remove(misc::qBittorrentPath()+"nova.py");
|
||||||
qDebug("Old nova removed");
|
qDebug("Old nova removed");
|
||||||
@ -2070,7 +2070,7 @@ void GUI::updateNova() const{
|
|||||||
qDebug("New nova copied");
|
qDebug("New nova copied");
|
||||||
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);
|
||||||
std::cout << "local search plugin updated\n";
|
qDebug("local search plugin updated");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2080,7 +2080,7 @@ void GUI::updateNova() const{
|
|||||||
void GUI::on_update_nova_button_clicked(){
|
void GUI::on_update_nova_button_clicked(){
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
std::string filePath;
|
std::string filePath;
|
||||||
std::cout << "Checking for search plugin updates on qbittorrent.org\n";
|
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()) {
|
||||||
@ -2089,12 +2089,12 @@ void GUI::on_update_nova_button_clicked(){
|
|||||||
delete tmpfile;
|
delete tmpfile;
|
||||||
FILE *file = fopen(filePath.c_str(), "w");
|
FILE *file = fopen(filePath.c_str(), "w");
|
||||||
if(!file){
|
if(!file){
|
||||||
std::cout << "Error: could not open temporary file...\n";
|
std::cerr << "Error: could not open temporary file...\n";
|
||||||
}
|
}
|
||||||
// Initilization required by libcurl
|
// Initilization required by libcurl
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
if(!curl){
|
if(!curl){
|
||||||
std::cout << "Error: Failed to init curl...\n";
|
std::cerr << "Error: Failed to init curl...\n";
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2113,14 +2113,14 @@ 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);
|
||||||
std::cout << "Version on qbittorrent.org: " << getNovaVersion(QString(filePath.c_str())) << '\n';
|
qDebug("Version on qbittorrent.org: %f", getNovaVersion(QString(filePath.c_str())));
|
||||||
float version_on_server = getNovaVersion(QString(filePath.c_str()));
|
float version_on_server = getNovaVersion(QString(filePath.c_str()));
|
||||||
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.c_str());
|
||||||
FILE *file = fopen(filePath.c_str(), "w");
|
FILE *file = fopen(filePath.c_str(), "w");
|
||||||
if(!file){
|
if(!file){
|
||||||
std::cout << "Error: could not open temporary file...\n";
|
std::cerr << "Error: could not open temporary file...\n";
|
||||||
}
|
}
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, "http://hydr0g3n.free.fr/nova/nova.py");
|
curl_easy_setopt(curl, CURLOPT_URL, "http://hydr0g3n.free.fr/nova/nova.py");
|
||||||
@ -2147,7 +2147,7 @@ void GUI::on_update_nova_button_clicked(){
|
|||||||
QString(), 0, 1)){
|
QString(), 0, 1)){
|
||||||
return;
|
return;
|
||||||
}else{
|
}else{
|
||||||
std::cout << "Updating search plugin from qbittorrent.org\n";
|
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(QString(filePath.c_str()), 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;
|
||||||
|
@ -78,13 +78,13 @@ class downloadThread : public QThread {
|
|||||||
delete tmpfile;
|
delete tmpfile;
|
||||||
FILE *file = fopen(filePath.c_str(), "w");
|
FILE *file = fopen(filePath.c_str(), "w");
|
||||||
if(!file){
|
if(!file){
|
||||||
std::cout << "Error: could not open temporary file...\n";
|
std::cerr << "Error: could not open temporary file...\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Initilization required by libcurl
|
// Initilization required by libcurl
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
if(!curl){
|
if(!curl){
|
||||||
std::cout << "Error: Failed to init curl...\n";
|
std::cerr << "Error: Failed to init curl...\n";
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ class downloadThread : public QThread {
|
|||||||
errorBuffer[0]=0; /* prevent junk from being output */
|
errorBuffer[0]=0; /* prevent junk from being output */
|
||||||
return_code = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
|
return_code = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
|
||||||
if(return_code){
|
if(return_code){
|
||||||
std::cout << "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.c_str());
|
||||||
return;
|
return;
|
||||||
|
14
src/main.cpp
14
src/main.cpp
@ -54,7 +54,7 @@ int main(int argc, char *argv[]){
|
|||||||
}
|
}
|
||||||
// Set environment variable
|
// Set environment variable
|
||||||
if(putenv("QBITTORRENT="VERSION)){
|
if(putenv("QBITTORRENT="VERSION)){
|
||||||
std::cout << "Couldn't set environment variable...\n";
|
std::cerr << "Couldn't set environment variable...\n";
|
||||||
}
|
}
|
||||||
// Buggy with Qt 4.1.2 : should try with another version
|
// Buggy with Qt 4.1.2 : should try with another version
|
||||||
//Check if there is another instance running
|
//Check if there is another instance running
|
||||||
@ -92,7 +92,7 @@ int main(int argc, char *argv[]){
|
|||||||
QTcpSocket tcpSocket;
|
QTcpSocket tcpSocket;
|
||||||
tcpSocket.connectToHost(QHostAddress::LocalHost, 1666);
|
tcpSocket.connectToHost(QHostAddress::LocalHost, 1666);
|
||||||
if (tcpSocket.waitForConnected(1000)){
|
if (tcpSocket.waitForConnected(1000)){
|
||||||
std::cout << "Another qBittorrent instance is already running...\n";
|
qDebug("Another qBittorrent instance is already running...");
|
||||||
// Write params to a temporary file
|
// Write params to a temporary file
|
||||||
QFile paramsFile(QDir::tempPath()+QDir::separator()+"qBT-params.txt");
|
QFile paramsFile(QDir::tempPath()+QDir::separator()+"qBT-params.txt");
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -105,17 +105,17 @@ int main(int argc, char *argv[]){
|
|||||||
paramsFile.remove();
|
paramsFile.remove();
|
||||||
// Write params to the file
|
// Write params to the file
|
||||||
if (!paramsFile.open(QIODevice::WriteOnly | QIODevice::Text)){
|
if (!paramsFile.open(QIODevice::WriteOnly | QIODevice::Text)){
|
||||||
std:: cout << "could not pass parameters\n";
|
std:: cerr << "could not pass parameters\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
std:: cout << "Passing parameters\n";
|
qDebug("Passing parameters");
|
||||||
for(int i=1;i<argc;++i){
|
for(int i=1;i<argc;++i){
|
||||||
paramsFile.write(QByteArray(argv[i]).append("\n"));
|
paramsFile.write(QByteArray(argv[i]).append("\n"));
|
||||||
}
|
}
|
||||||
paramsFile.close();
|
paramsFile.close();
|
||||||
tcpSocket.disconnectFromHost();
|
tcpSocket.disconnectFromHost();
|
||||||
tcpSocket.close();
|
tcpSocket.close();
|
||||||
std:: cout << "exiting\n";
|
qDebug("exiting");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
@ -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)){
|
||||||
std::cout << locale.toStdString() << " locale recognized, using translation.\n";
|
qDebug("%s locale recognized, using translation.", locale.toStdString().c_str());
|
||||||
}else{
|
}else{
|
||||||
std::cout << locale.toStdString() << " locale unrecognized, using default (en_GB).\n";
|
qDebug("%s locale unrecognized, using default (en_GB).", locale.toStdString().c_str());
|
||||||
}
|
}
|
||||||
app.installTranslator(&translator);
|
app.installTranslator(&translator);
|
||||||
// Read torrents given on command line
|
// Read torrents given on command line
|
||||||
|
@ -97,7 +97,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
|||||||
saveOptions();
|
saveOptions();
|
||||||
}
|
}
|
||||||
if(!loadOptions()){
|
if(!loadOptions()){
|
||||||
std::cout << "Warning: Couldn't load options" << '\n';
|
std::cerr << "Warning: Couldn't load options" << '\n';
|
||||||
}
|
}
|
||||||
// Connect signals / slots
|
// Connect signals / slots
|
||||||
connect(disableUPLimit, SIGNAL(stateChanged(int)), this, SLOT(disableUpload(int)));
|
connect(disableUPLimit, SIGNAL(stateChanged(int)), this, SLOT(disableUpload(int)));
|
||||||
@ -308,17 +308,17 @@ bool options_imp::saveOptions(){
|
|||||||
// Write XML file to HD
|
// Write XML file to HD
|
||||||
f = fopen(savePath.toStdString().c_str(), "w");
|
f = fopen(savePath.toStdString().c_str(), "w");
|
||||||
if (!f){
|
if (!f){
|
||||||
std::cout << "Error: Couldn't create file " << savePath.toStdString() << " for saving!" << '\n';
|
std::cerr << "Error: Couldn't create file " << savePath.toStdString() << " for saving!" << '\n';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!file.open(f, QIODevice::WriteOnly | QIODevice::Text)){
|
if (!file.open(f, QIODevice::WriteOnly | QIODevice::Text)){
|
||||||
std::cout << "Error: Couldn't open file " << savePath.toStdString() << " for saving!" << '\n';
|
std::cerr << "Error: Couldn't open file " << savePath.toStdString() << " for saving!" << '\n';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
file.write(xml.toStdString().c_str(), xml.length());
|
file.write(xml.toStdString().c_str(), xml.length());
|
||||||
file.close();
|
file.close();
|
||||||
if(fclose(f) == EOF){
|
if(fclose(f) == EOF){
|
||||||
std::cout << "Error: Couldn't close file " << savePath.toStdString() << " after saving!" << '\n';
|
std::cerr << "Error: Couldn't close file " << savePath.toStdString() << " after saving!" << '\n';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// set infobar text
|
// set infobar text
|
||||||
@ -360,7 +360,7 @@ bool options_imp::loadOptions(){
|
|||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
if(fclose(f) == EOF){
|
if(fclose(f) == EOF){
|
||||||
std::cout << "Error: Couldn't close file " << savePath.toStdString() << " after reading!" << '\n';
|
std::cerr << "Error: Couldn't close file " << savePath.toStdString() << " after reading!" << '\n';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Loading option from XML
|
// Loading option from XML
|
||||||
@ -799,7 +799,7 @@ void options_imp::processFilterFile(const QString& filePath){
|
|||||||
QList<QByteArray> partsList = line.split(',');
|
QList<QByteArray> partsList = line.split(',');
|
||||||
unsigned int nbElem = partsList.size();
|
unsigned int nbElem = partsList.size();
|
||||||
if(nbElem < 2){
|
if(nbElem < 2){
|
||||||
std::cout << "Ipfilter.dat: line " << nbLine << " is malformed.\n";
|
std::cerr << "Ipfilter.dat: line " << nbLine << " is malformed.\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int nbAccess = partsList.at(1).trimmed().toInt();
|
int nbAccess = partsList.at(1).trimmed().toInt();
|
||||||
@ -815,13 +815,13 @@ void options_imp::processFilterFile(const QString& filePath){
|
|||||||
// Split IP
|
// Split IP
|
||||||
IP = strStartIP.split('.');
|
IP = strStartIP.split('.');
|
||||||
if(IP.size() != 4){
|
if(IP.size() != 4){
|
||||||
std::cout << "Ipfilter.dat: line " << nbLine << ", first IP is malformed.\n";
|
std::cerr << "Ipfilter.dat: line " << nbLine << ", first IP is malformed.\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
address_v4 start((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
address_v4 start((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
||||||
IP = strEndIP.split('.');
|
IP = strEndIP.split('.');
|
||||||
if(IP.size() != 4){
|
if(IP.size() != 4){
|
||||||
std::cout << "Ipfilter.dat: line " << nbLine << ", second IP is malformed.\n";
|
std::cerr << "Ipfilter.dat: line " << nbLine << ", second IP is malformed.\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
address_v4 last((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
address_v4 last((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
||||||
@ -896,7 +896,7 @@ void options_imp::on_addFilterRange_clicked(){
|
|||||||
}
|
}
|
||||||
QFile ipfilter(misc::qBittorrentPath() + "ipfilter.dat");
|
QFile ipfilter(misc::qBittorrentPath() + "ipfilter.dat");
|
||||||
if (!ipfilter.open(QIODevice::Append | QIODevice::WriteOnly | QIODevice::Text)){
|
if (!ipfilter.open(QIODevice::Append | QIODevice::WriteOnly | QIODevice::Text)){
|
||||||
std::cout << "Error: Couldn't write in ipfilter.dat";
|
std::cerr << "Error: Couldn't write in ipfilter.dat";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QTextStream out(&ipfilter);
|
QTextStream out(&ipfilter);
|
||||||
@ -925,7 +925,7 @@ void options_imp::on_delFilterRange_clicked(){
|
|||||||
// Update ipfilter.dat
|
// Update ipfilter.dat
|
||||||
QFile ipfilter(misc::qBittorrentPath() + "ipfilter.dat");
|
QFile ipfilter(misc::qBittorrentPath() + "ipfilter.dat");
|
||||||
if (!ipfilter.open(QIODevice::WriteOnly | QIODevice::Text)){
|
if (!ipfilter.open(QIODevice::WriteOnly | QIODevice::Text)){
|
||||||
std::cout << "Error: Couldn't write in ipfilter.dat";
|
std::cerr << "Error: Couldn't write in ipfilter.dat";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QTextStream out(&ipfilter);
|
QTextStream out(&ipfilter);
|
||||||
|
@ -163,7 +163,7 @@ void properties::loadFilteredFiles(){
|
|||||||
pieces_file.close();
|
pieces_file.close();
|
||||||
QList<QByteArray> pieces_selection_list = pieces_selection.split('\n');
|
QList<QByteArray> pieces_selection_list = pieces_selection.split('\n');
|
||||||
if(pieces_selection_list.size() != torrentInfo.num_files()+1){
|
if(pieces_selection_list.size() != torrentInfo.num_files()+1){
|
||||||
std::cout << "Error: Corrupted pieces file\n";
|
std::cerr << "Error: Corrupted pieces file\n";
|
||||||
setAllPiecesState(true);
|
setAllPiecesState(true);
|
||||||
selectionBitmask.assign(torrentInfo.num_files(), 0);
|
selectionBitmask.assign(torrentInfo.num_files(), 0);
|
||||||
return;
|
return;
|
||||||
@ -309,7 +309,7 @@ void properties::saveFilteredFiles(){
|
|||||||
pieces_file.remove();
|
pieces_file.remove();
|
||||||
// Write new files
|
// Write new files
|
||||||
if(!pieces_file.open(QIODevice::WriteOnly | QIODevice::Text)){
|
if(!pieces_file.open(QIODevice::WriteOnly | QIODevice::Text)){
|
||||||
std::cout << "Error: Could not save filtered pieces\n";
|
std::cerr << "Error: Could not save filtered pieces\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(int i=0; i<torrentInfo.num_files(); ++i){
|
for(int i=0; i<torrentInfo.num_files(); ++i){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user