mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +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
|
||||
tcpServer = new QTcpServer(this);
|
||||
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()));
|
||||
// Start connection checking timer
|
||||
@ -427,7 +427,7 @@ void GUI::readParamsInFile(){
|
||||
params << line;
|
||||
}
|
||||
if(params.size()){
|
||||
std::cout << "Received parameters from another instance\n";
|
||||
qDebug("Received parameters from another instance");
|
||||
addTorrents(params);
|
||||
}
|
||||
paramsFile.close();
|
||||
@ -470,7 +470,7 @@ void GUI::updateDlList(){
|
||||
if(!h.is_paused()){
|
||||
int row = getRowFromName(fileName);
|
||||
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;
|
||||
}
|
||||
// Parse download state
|
||||
@ -721,7 +721,7 @@ void GUI::saveWindowSize() const{
|
||||
lastWindowSize.close();
|
||||
qDebug("Saved window size");
|
||||
}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();
|
||||
QList<QByteArray> pieces_selection_list = pieces_selection.split('\n');
|
||||
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;
|
||||
}
|
||||
std::vector<bool> selectionBitmask;
|
||||
@ -831,7 +831,7 @@ void GUI::saveCheckedSearchEngines(int) const{
|
||||
lastSearchEngines.close();
|
||||
qDebug("Saved checked search engines");
|
||||
}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();
|
||||
qDebug("Columns width saved");
|
||||
}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");
|
||||
return true;
|
||||
}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;
|
||||
}
|
||||
}
|
||||
@ -898,7 +898,7 @@ void GUI::saveColWidthSearchList() const{
|
||||
lastSearchListWidth.close();
|
||||
qDebug("Columns width saved in search list");
|
||||
}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");
|
||||
return true;
|
||||
}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;
|
||||
}
|
||||
}
|
||||
@ -974,7 +974,7 @@ void GUI::loadCheckedSearchEngines(){
|
||||
}
|
||||
qDebug("Checked search engines loaded");
|
||||
}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);
|
||||
bencode(std::ostream_iterator<char>(out), dht_state);
|
||||
}catch (std::exception& e){
|
||||
std::cout << e.what() << "\n";
|
||||
std::cerr << e.what() << "\n";
|
||||
}
|
||||
}
|
||||
// Save window size, columns size
|
||||
@ -1242,7 +1242,7 @@ void GUI::deleteSelection(){
|
||||
--nbTorrents;
|
||||
tabs->setTabText(0, tr("Transfers") +" ("+QString(misc::toString(nbTorrents).c_str())+")");
|
||||
}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;
|
||||
tabs->setTabText(0, tr("Transfers") +" ("+QString(misc::toString(nbTorrents).c_str())+")");
|
||||
}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
|
||||
if(!from_url.isNull()){
|
||||
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;
|
||||
}
|
||||
if(h.is_valid()){
|
||||
std::cout << "Error: Couldn't reload the torrent\n";
|
||||
std::cerr << "Error: Couldn't reload the torrent\n";
|
||||
return;
|
||||
}
|
||||
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){
|
||||
std::cout << e.what() << "\n";
|
||||
std::cerr << e.what() << "\n";
|
||||
}
|
||||
qDebug("Session configured");
|
||||
}
|
||||
@ -1688,7 +1688,7 @@ void GUI::pauseAll(){
|
||||
// update DL Status
|
||||
int row = getRowFromName(fileName);
|
||||
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;
|
||||
}
|
||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.));
|
||||
@ -1750,7 +1750,7 @@ void GUI::startAll(){
|
||||
// update DL Status
|
||||
int row = getRowFromName(fileName);
|
||||
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;
|
||||
}
|
||||
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(misc::qBittorrentPath()+"nova.py").setPermissions(perm);
|
||||
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
|
||||
QFile::remove(misc::qBittorrentPath()+"nova.py");
|
||||
qDebug("Old nova removed");
|
||||
@ -2070,7 +2070,7 @@ void GUI::updateNova() const{
|
||||
qDebug("New nova copied");
|
||||
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);
|
||||
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(){
|
||||
CURL *curl;
|
||||
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
|
||||
QTemporaryFile *tmpfile = new QTemporaryFile;
|
||||
if (tmpfile->open()) {
|
||||
@ -2089,12 +2089,12 @@ void GUI::on_update_nova_button_clicked(){
|
||||
delete tmpfile;
|
||||
FILE *file = fopen(filePath.c_str(), "w");
|
||||
if(!file){
|
||||
std::cout << "Error: could not open temporary file...\n";
|
||||
std::cerr << "Error: could not open temporary file...\n";
|
||||
}
|
||||
// Initilization required by libcurl
|
||||
curl = curl_easy_init();
|
||||
if(!curl){
|
||||
std::cout << "Error: Failed to init curl...\n";
|
||||
std::cerr << "Error: Failed to init curl...\n";
|
||||
fclose(file);
|
||||
return;
|
||||
}
|
||||
@ -2113,14 +2113,14 @@ void GUI::on_update_nova_button_clicked(){
|
||||
curl_easy_cleanup(curl);
|
||||
// Close tmp 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()));
|
||||
if(version_on_server == 0.0){
|
||||
//First server is down, try mirror
|
||||
QFile::remove(filePath.c_str());
|
||||
FILE *file = fopen(filePath.c_str(), "w");
|
||||
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_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)){
|
||||
return;
|
||||
}else{
|
||||
std::cout << "Updating search plugin from qbittorrent.org\n";
|
||||
qDebug("Updating search plugin from qbittorrent.org");
|
||||
QFile::remove(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;
|
||||
|
@ -78,13 +78,13 @@ class downloadThread : public QThread {
|
||||
delete tmpfile;
|
||||
FILE *file = fopen(filePath.c_str(), "w");
|
||||
if(!file){
|
||||
std::cout << "Error: could not open temporary file...\n";
|
||||
std::cerr << "Error: could not open temporary file...\n";
|
||||
return;
|
||||
}
|
||||
// Initilization required by libcurl
|
||||
curl = curl_easy_init();
|
||||
if(!curl){
|
||||
std::cout << "Error: Failed to init curl...\n";
|
||||
std::cerr << "Error: Failed to init curl...\n";
|
||||
fclose(file);
|
||||
return;
|
||||
}
|
||||
@ -114,7 +114,7 @@ class downloadThread : public QThread {
|
||||
errorBuffer[0]=0; /* prevent junk from being output */
|
||||
return_code = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
|
||||
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);
|
||||
QFile::remove(filePath.c_str());
|
||||
return;
|
||||
|
14
src/main.cpp
14
src/main.cpp
@ -54,7 +54,7 @@ int main(int argc, char *argv[]){
|
||||
}
|
||||
// Set environment variable
|
||||
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
|
||||
//Check if there is another instance running
|
||||
@ -92,7 +92,7 @@ int main(int argc, char *argv[]){
|
||||
QTcpSocket tcpSocket;
|
||||
tcpSocket.connectToHost(QHostAddress::LocalHost, 1666);
|
||||
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
|
||||
QFile paramsFile(QDir::tempPath()+QDir::separator()+"qBT-params.txt");
|
||||
int count = 0;
|
||||
@ -105,17 +105,17 @@ int main(int argc, char *argv[]){
|
||||
paramsFile.remove();
|
||||
// Write params to the file
|
||||
if (!paramsFile.open(QIODevice::WriteOnly | QIODevice::Text)){
|
||||
std:: cout << "could not pass parameters\n";
|
||||
std:: cerr << "could not pass parameters\n";
|
||||
return 1;
|
||||
}
|
||||
std:: cout << "Passing parameters\n";
|
||||
qDebug("Passing parameters");
|
||||
for(int i=1;i<argc;++i){
|
||||
paramsFile.write(QByteArray(argv[i]).append("\n"));
|
||||
}
|
||||
paramsFile.close();
|
||||
tcpSocket.disconnectFromHost();
|
||||
tcpSocket.close();
|
||||
std:: cout << "exiting\n";
|
||||
qDebug("exiting");
|
||||
return 0;
|
||||
}
|
||||
QApplication app(argc, argv);
|
||||
@ -145,9 +145,9 @@ int main(int argc, char *argv[]){
|
||||
locale = QLocale::system().name();
|
||||
}
|
||||
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{
|
||||
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);
|
||||
// Read torrents given on command line
|
||||
|
@ -97,7 +97,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
|
||||
saveOptions();
|
||||
}
|
||||
if(!loadOptions()){
|
||||
std::cout << "Warning: Couldn't load options" << '\n';
|
||||
std::cerr << "Warning: Couldn't load options" << '\n';
|
||||
}
|
||||
// Connect signals / slots
|
||||
connect(disableUPLimit, SIGNAL(stateChanged(int)), this, SLOT(disableUpload(int)));
|
||||
@ -308,17 +308,17 @@ bool options_imp::saveOptions(){
|
||||
// Write XML file to HD
|
||||
f = fopen(savePath.toStdString().c_str(), "w");
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
file.write(xml.toStdString().c_str(), xml.length());
|
||||
file.close();
|
||||
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;
|
||||
}
|
||||
// set infobar text
|
||||
@ -360,7 +360,7 @@ bool options_imp::loadOptions(){
|
||||
}
|
||||
file.close();
|
||||
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;
|
||||
}
|
||||
// Loading option from XML
|
||||
@ -799,7 +799,7 @@ void options_imp::processFilterFile(const QString& filePath){
|
||||
QList<QByteArray> partsList = line.split(',');
|
||||
unsigned int nbElem = partsList.size();
|
||||
if(nbElem < 2){
|
||||
std::cout << "Ipfilter.dat: line " << nbLine << " is malformed.\n";
|
||||
std::cerr << "Ipfilter.dat: line " << nbLine << " is malformed.\n";
|
||||
continue;
|
||||
}
|
||||
int nbAccess = partsList.at(1).trimmed().toInt();
|
||||
@ -815,13 +815,13 @@ void options_imp::processFilterFile(const QString& filePath){
|
||||
// Split IP
|
||||
IP = strStartIP.split('.');
|
||||
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;
|
||||
}
|
||||
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('.');
|
||||
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;
|
||||
}
|
||||
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");
|
||||
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;
|
||||
}
|
||||
QTextStream out(&ipfilter);
|
||||
@ -925,7 +925,7 @@ void options_imp::on_delFilterRange_clicked(){
|
||||
// Update ipfilter.dat
|
||||
QFile ipfilter(misc::qBittorrentPath() + "ipfilter.dat");
|
||||
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;
|
||||
}
|
||||
QTextStream out(&ipfilter);
|
||||
|
@ -163,7 +163,7 @@ void properties::loadFilteredFiles(){
|
||||
pieces_file.close();
|
||||
QList<QByteArray> pieces_selection_list = pieces_selection.split('\n');
|
||||
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);
|
||||
selectionBitmask.assign(torrentInfo.num_files(), 0);
|
||||
return;
|
||||
@ -309,7 +309,7 @@ void properties::saveFilteredFiles(){
|
||||
pieces_file.remove();
|
||||
// Write new files
|
||||
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;
|
||||
}
|
||||
for(int i=0; i<torrentInfo.num_files(); ++i){
|
||||
|
Loading…
x
Reference in New Issue
Block a user