Coding style clean up

This commit is contained in:
Christophe Dumez
2012-02-20 19:56:07 +02:00
parent 00b4ad6ec8
commit f3448125c3
40 changed files with 227 additions and 228 deletions

View File

@@ -59,7 +59,7 @@ public:
}
~FilterParserThread(){
~FilterParserThread() {
abort = true;
wait();
}
@@ -68,8 +68,8 @@ public:
int parseDATFilterFile(QString filePath) {
int ruleCount = 0;
QFile file(filePath);
if (file.exists()){
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){
if (file.exists()) {
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
std::cerr << "I/O Error: Could not open ip filer file in read mode." << std::endl;
return ruleCount;
}
@@ -141,7 +141,7 @@ public:
try {
filter.add_rule(startAddr, endAddr, libtorrent::ip_filter::blocked);
++ruleCount;
}catch(exception){
}catch(exception) {
qDebug("Bad line in filter file, avoided crash...");
}
}
@@ -154,8 +154,8 @@ public:
int parseP2PFilterFile(QString filePath) {
int ruleCount = 0;
QFile file(filePath);
if (file.exists()){
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){
if (file.exists()) {
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
std::cerr << "I/O Error: Could not open ip filer file in read mode." << std::endl;
return ruleCount;
}
@@ -168,7 +168,7 @@ public:
if (line.startsWith('#') || line.startsWith("//")) continue;
// Line is splitted by :
QList<QByteArray> partsList = line.split(':');
if (partsList.size() < 2){
if (partsList.size() < 2) {
qDebug("p2p file: line %d is malformed.", nbLine);
continue;
}
@@ -246,8 +246,8 @@ public:
int parseP2BFilterFile(QString filePath) {
int ruleCount = 0;
QFile file(filePath);
if (file.exists()){
if (!file.open(QIODevice::ReadOnly)){
if (file.exists()) {
if (!file.open(QIODevice::ReadOnly)) {
std::cerr << "I/O Error: Could not open ip filer file in read mode." << std::endl;
return ruleCount;
}
@@ -351,7 +351,7 @@ public:
// * eMule IP list (DAT): http://wiki.phoenixlabs.org/wiki/DAT_Format
// * PeerGuardian Text (P2P): http://wiki.phoenixlabs.org/wiki/P2P_Format
// * PeerGuardian Binary (P2B): http://wiki.phoenixlabs.org/wiki/P2B_Format
void processFilterFile(QString _filePath){
void processFilterFile(QString _filePath) {
// First, import current filter
filter = s->get_ip_filter();
if (isRunning()) {
@@ -392,7 +392,7 @@ protected:
return ip.toString();
}
void run(){
void run() {
qDebug("Processing filter file");
int ruleCount = 0;
if (filePath.endsWith(".p2p", Qt::CaseInsensitive)) {
@@ -412,7 +412,7 @@ protected:
try {
s->set_ip_filter(filter);
emit IPFilterParsed(ruleCount);
} catch(std::exception&){
} catch(std::exception&) {
emit IPFilterError();
}
qDebug("IP Filter thread: finished parsing, filter applied");

View File

@@ -922,7 +922,7 @@ QTorrentHandle QBtSession::addMagnetUri(QString magnet_uri, bool resumed) {
// Adding torrent to Bittorrent session
try {
h = QTorrentHandle(add_magnet_uri(*s, magnet_uri.toStdString(), p));
}catch(std::exception e){
}catch(std::exception e) {
qDebug("Error: %s", e.what());
}
// Check if it worked
@@ -1114,7 +1114,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
// Adding torrent to Bittorrent session
try {
h = QTorrentHandle(s->add_torrent(p));
}catch(std::exception e){
}catch(std::exception e) {
qDebug("Error: %s", e.what());
}
// Check if it worked
@@ -1585,7 +1585,7 @@ void QBtSession::saveTempFastResumeData() {
if (h.state() == torrent_status::checking_files || h.state() == torrent_status::queued_for_checking) continue;
qDebug("Saving fastresume data for %s", qPrintable(h.name()));
h.save_resume_data();
}catch(std::exception e){}
}catch(std::exception e) {}
}
}
@@ -1630,7 +1630,7 @@ void QBtSession::saveFastResumeData() {
// Remove torrent from session
if (rda->handle.is_valid())
s->remove_torrent(rda->handle);
}catch(libtorrent::libtorrent_exception){}
}catch(libtorrent::libtorrent_exception) {}
continue;
}
save_resume_data_alert const* rd = dynamic_cast<save_resume_data_alert const*>(a);
@@ -1659,7 +1659,7 @@ void QBtSession::saveFastResumeData() {
// Remove torrent from session
s->remove_torrent(rd->handle);
s->pop_alert();
} catch(libtorrent::invalid_handle&){}
} catch(libtorrent::invalid_handle&) {}
}
}
@@ -2405,7 +2405,7 @@ void QBtSession::readAlerts() {
else if (tracker_error_alert* p = dynamic_cast<tracker_error_alert*>(a.get())) {
// Level: fatal
QTorrentHandle h(p->handle);
if (h.is_valid()){
if (h.is_valid()) {
// Authentication
if (p->status_code != 401) {
qDebug("Received a tracker error for %s: %s", p->url.c_str(), p->msg.c_str());
@@ -2422,7 +2422,7 @@ void QBtSession::readAlerts() {
}
else if (tracker_reply_alert* p = dynamic_cast<tracker_reply_alert*>(a.get())) {
const QTorrentHandle h(p->handle);
if (h.is_valid()){
if (h.is_valid()) {
qDebug("Received a tracker reply from %s (Num_peers=%d)", p->url.c_str(), p->num_peers);
// Connection was successful now. Remove possible old errors
QHash<QString, TrackerInfos> trackers_data = trackersInfos.value(h.hash(), QHash<QString, TrackerInfos>());
@@ -2435,7 +2435,7 @@ void QBtSession::readAlerts() {
}
} else if (tracker_warning_alert* p = dynamic_cast<tracker_warning_alert*>(a.get())) {
const QTorrentHandle h(p->handle);
if (h.is_valid()){
if (h.is_valid()) {
// Connection was successful now but there is a warning message
QHash<QString, TrackerInfos> trackers_data = trackersInfos.value(h.hash(), QHash<QString, TrackerInfos>());
const QString tracker_url = misc::toQString(p->url);
@@ -2504,7 +2504,7 @@ void QBtSession::readAlerts() {
}
else if (torrent_checked_alert* p = dynamic_cast<torrent_checked_alert*>(a.get())) {
QTorrentHandle h(p->handle);
if (h.is_valid()){
if (h.is_valid()) {
const QString hash = h.hash();
qDebug("%s have just finished checking", qPrintable(hash));
// Save seed status

View File

@@ -41,7 +41,7 @@ using namespace libtorrent;
class SpeedSample {
public:
SpeedSample(){}
SpeedSample() {}
void addSample(int s);
qreal average() const;
void clear();
@@ -106,7 +106,7 @@ void TorrentSpeedMonitor::removeSamples(const QString &hash)
void TorrentSpeedMonitor::removeSamples(const QTorrentHandle& h) {
try {
m_samples.remove(h.hash());
} catch(invalid_handle&){}
} catch(invalid_handle&) {}
}
qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const
@@ -133,6 +133,6 @@ void TorrentSpeedMonitor::getSamples()
if (!it->is_paused())
m_samples[misc::toQString(it->info_hash())].addSample(it->status().download_payload_rate);
#endif
} catch(invalid_handle&){}
} catch(invalid_handle&) {}
}
}