Mercurial > hg > svcore
diff data/fileio/FileSource.cpp @ 689:573d45e9487b
Merge from debug-output branch
author | Chris Cannam |
---|---|
date | Tue, 14 Jun 2011 14:47:59 +0100 |
parents | 06f13a3b9e9e |
children | 1424aa29ae95 |
line wrap: on
line diff
--- a/data/fileio/FileSource.cpp Tue Jun 14 13:43:03 2011 +0100 +++ b/data/fileio/FileSource.cpp Tue Jun 14 14:47:59 2011 +0100 @@ -88,12 +88,12 @@ } #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::FileSource(" << fileOrUrl.toStdString() << "): url <" << m_url.toString().toStdString() << ">" << std::endl; + DEBUG << "FileSource::FileSource(" << fileOrUrl << "): url <" << m_url.toString() << ">" << endl; incCount(m_url.toString()); #endif if (!canHandleScheme(m_url)) { - std::cerr << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString().toStdString() << "\"" << std::endl; + DEBUG << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << endl; m_errorString = tr("Unsupported scheme in URL"); return; } @@ -103,7 +103,7 @@ if (!isRemote() && !isAvailable()) { #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::FileSource: Failed to open local file with URL \"" << m_url.toString().toStdString() << "; trying again assuming filename was encoded" << std::endl; + std::cerr << "FileSource::FileSource: Failed to open local file with URL \"" << m_url.toString() << "; trying again assuming filename was encoded" << std::endl; #endif m_url = QUrl::fromEncoded(fileOrUrl.toAscii()); init(); @@ -148,7 +148,7 @@ } #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::FileSource(string) exiting" << std::endl; + DEBUG << "FileSource::FileSource(string) exiting" << endl; #endif } @@ -166,12 +166,12 @@ m_refCounted(false) { #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::FileSource(" << url.toString().toStdString() << ") [as url]" << std::endl; + DEBUG << "FileSource::FileSource(" << url.toString() << ") [as url]" << endl; incCount(m_url.toString()); #endif if (!canHandleScheme(m_url)) { - std::cerr << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString().toStdString() << "\"" << std::endl; + DEBUG << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << endl; m_errorString = tr("Unsupported scheme in URL"); return; } @@ -179,7 +179,7 @@ init(); #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::FileSource(url) exiting" << std::endl; + DEBUG << "FileSource::FileSource(url) exiting" << endl; #endif } @@ -198,12 +198,12 @@ m_refCounted(false) { #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::FileSource(" << m_url.toString().toStdString() << ") [copy ctor]" << std::endl; + DEBUG << "FileSource::FileSource(" << m_url.toString() << ") [copy ctor]" << endl; incCount(m_url.toString()); #endif if (!canHandleScheme(m_url)) { - std::cerr << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString().toStdString() << "\"" << std::endl; + DEBUG << "FileSource::FileSource: ERROR: Unsupported scheme in URL \"" << m_url.toString() << "\"" << endl; m_errorString = tr("Unsupported scheme in URL"); return; } @@ -213,8 +213,8 @@ } else { QMutexLocker locker(&m_mapMutex); #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::FileSource(copy ctor): ref count is " - << m_refCountMap[m_url] << std::endl; + DEBUG << "FileSource::FileSource(copy ctor): ref count is " + << m_refCountMap[m_url] << endl; #endif if (m_refCountMap[m_url] > 0) { m_refCountMap[m_url]++; @@ -232,18 +232,18 @@ m_done = true; #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::FileSource(" << m_url.toString().toStdString() << ") [copy ctor]: note: local filename is \"" << m_localFilename.toStdString() << "\"" << std::endl; + DEBUG << "FileSource::FileSource(" << m_url.toString() << ") [copy ctor]: note: local filename is \"" << m_localFilename << "\"" << endl; #endif #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::FileSource(copy ctor) exiting" << std::endl; + DEBUG << "FileSource::FileSource(copy ctor) exiting" << endl; #endif } FileSource::~FileSource() { #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource(" << m_url.toString().toStdString() << ")::~FileSource" << std::endl; + std::cerr << "FileSource(" << m_url.toString() << ")::~FileSource" << std::endl; decCount(m_url.toString()); #endif @@ -257,7 +257,7 @@ { if (!isRemote()) { #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::init: Not a remote URL" << std::endl; + DEBUG << "FileSource::init: Not a remote URL" << endl; #endif bool literal = false; m_localFilename = m_url.toLocalFile(); @@ -269,8 +269,8 @@ m_localFilename = QFileInfo(m_localFilename).absoluteFilePath(); #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::init: URL translates to local filename \"" - << m_localFilename.toStdString() << "\" (with literal=" << literal << ")" << std::endl; + DEBUG << "FileSource::init: URL translates to local filename \"" + << m_localFilename << "\" (with literal=" << literal << ")" << endl; #endif m_ok = true; m_lastStatus = 200; @@ -280,7 +280,7 @@ m_lastStatus = 404; } else { #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::init: Local file of this name does not exist, trying URL as a literal filename" << std::endl; + DEBUG << "FileSource::init: Local file of this name does not exist, trying URL as a literal filename" << endl; #endif // Again, QUrl may have been mistreating us -- // e.g. dropping a part that looks like query data @@ -298,7 +298,7 @@ if (createCacheFile()) { #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::init: Already have this one" << std::endl; + DEBUG << "FileSource::init: Already have this one" << endl; #endif m_ok = true; if (!QFileInfo(m_localFilename).exists()) { @@ -317,8 +317,8 @@ QString scheme = m_url.scheme().toLower(); #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::init: Don't have local copy of \"" - << m_url.toString().toStdString() << "\", retrieving" << std::endl; + DEBUG << "FileSource::init: Don't have local copy of \"" + << m_url.toString() << "\", retrieving" << endl; #endif if (scheme == "http") { @@ -343,7 +343,7 @@ cleanup(); m_refCountMap[m_url]++; #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::init: Another FileSource has got there first, abandoning our download and using theirs" << std::endl; + DEBUG << "FileSource::init: Another FileSource has got there first, abandoning our download and using theirs" << endl; #endif m_localFilename = m_remoteLocalMap[m_url]; m_refCounted = true; @@ -426,8 +426,8 @@ QString path = "/" + QString(m_url.toEncoded()).section('/', 3); #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource: path is \"" - << path.toStdString() << "\"" << std::endl; + DEBUG << "FileSource: path is \"" + << path << "\"" << endl; #endif if (m_preferredContentType == "") { @@ -435,7 +435,7 @@ } else { #ifdef DEBUG_FILE_SOURCE std::cerr << "FileSource: indicating preferred content type of \"" - << m_preferredContentType.toStdString() << "\"" << std::endl; + << m_preferredContentType << "\"" << std::endl; #endif QHttpRequestHeader header("GET", path); header.setValue("Host", m_url.host()); @@ -528,8 +528,8 @@ if (!m_ok) available = false; else available = (m_lastStatus / 100 == 2); #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::isAvailable: " << (available ? "yes" : "no") - << std::endl; + DEBUG << "FileSource::isAvailable: " << (available ? "yes" : "no") + << endl; #endif return available; } @@ -547,7 +547,7 @@ FileSource::waitForData() { while (m_ok && !m_done) { -// std::cerr << "FileSource::waitForData: calling QApplication::processEvents" << std::endl; +// DEBUG << "FileSource::waitForData: calling QApplication::processEvents" << endl; QCoreApplication::processEvents(); usleep(10000); } @@ -627,14 +627,14 @@ FileSource::httpResponseHeaderReceived(const QHttpResponseHeader &resp) { #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::httpResponseHeaderReceived" << std::endl; + DEBUG << "FileSource::httpResponseHeaderReceived" << endl; #endif if (resp.statusCode() / 100 == 3) { QString location = resp.value("Location"); #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::responseHeaderReceived: redirect to \"" - << location.toStdString() << "\" received" << std::endl; + DEBUG << "FileSource::responseHeaderReceived: redirect to \"" + << location << "\" received" << endl; #endif if (location != "") { QUrl newUrl(location); @@ -661,13 +661,13 @@ m_errorString = QString("%1 %2") .arg(resp.statusCode()).arg(resp.reasonPhrase()); #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::responseHeaderReceived: " - << m_errorString.toStdString() << std::endl; + DEBUG << "FileSource::responseHeaderReceived: " + << m_errorString << endl; #endif } else { #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::responseHeaderReceived: " - << m_lastStatus << std::endl; + DEBUG << "FileSource::responseHeaderReceived: " + << m_lastStatus << endl; #endif if (resp.hasContentType()) m_contentType = resp.contentType(); } @@ -687,8 +687,8 @@ if (!error) { #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::ftpCommandFinished: success for command " - << command << std::endl; + DEBUG << "FileSource::ftpCommandFinished: success for command " + << command << endl; #endif return; } @@ -776,7 +776,7 @@ FileSource::deleteCacheFile() { #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::deleteCacheFile(\"" << m_localFilename.toStdString() << "\")" << std::endl; + DEBUG << "FileSource::deleteCacheFile(\"" << m_localFilename << "\")" << endl; #endif cleanup(); @@ -813,11 +813,11 @@ if (!QFile(m_localFilename).remove()) { #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::deleteCacheFile: ERROR: Failed to delete file \"" << m_localFilename.toStdString() << "\"" << std::endl; + std::cerr << "FileSource::deleteCacheFile: ERROR: Failed to delete file \"" << m_localFilename << "\"" << std::endl; #endif } else { #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::deleteCacheFile: Deleted cache file \"" << m_localFilename.toStdString() << "\"" << std::endl; + DEBUG << "FileSource::deleteCacheFile: Deleted cache file \"" << m_localFilename << "\"" << endl; #endif m_localFilename = ""; } @@ -834,7 +834,7 @@ QMutexLocker locker(&m_mapMutex); #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::createCacheFile: refcount is " << m_refCountMap[m_url] << std::endl; + DEBUG << "FileSource::createCacheFile: refcount is " << m_refCountMap[m_url] << endl; #endif if (m_refCountMap[m_url] > 0) { @@ -881,7 +881,7 @@ QString filepath(dir.filePath(filename)); #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::createCacheFile: URL is \"" << m_url.toString().toStdString() << "\", dir is \"" << dir.path().toStdString() << "\", base \"" << base.toStdString() << "\", extension \"" << extension.toStdString() << "\", filebase \"" << filename.toStdString() << "\", filename \"" << filepath.toStdString() << "\"" << std::endl; + DEBUG << "FileSource::createCacheFile: URL is \"" << m_url.toString() << "\", dir is \"" << dir.path() << "\", base \"" << base << "\", extension \"" << extension << "\", filebase \"" << filename << "\", filename \"" << filepath << "\"" << endl; #endif QMutexLocker fcLocker(&m_fileCreationMutex); @@ -893,8 +893,8 @@ #ifdef DEBUG_FILE_SOURCE std::cerr << "FileSource::createCacheFile: Failed to create local file \"" - << filepath.toStdString() << "\" for URL \"" - << m_url.toString().toStdString() << "\" (or file already exists): appending suffix instead" << std::endl; + << filepath << "\" for URL \"" + << m_url.toString() << "\" (or file already exists): appending suffix instead" << std::endl; #endif if (extension == "") { @@ -909,8 +909,8 @@ #ifdef DEBUG_FILE_SOURCE std::cerr << "FileSource::createCacheFile: ERROR: Failed to create local file \"" - << filepath.toStdString() << "\" for URL \"" - << m_url.toString().toStdString() << "\" (or file already exists)" << std::endl; + << filepath << "\" for URL \"" + << m_url.toString() << "\" (or file already exists)" << std::endl; #endif return ""; @@ -918,9 +918,9 @@ } #ifdef DEBUG_FILE_SOURCE - std::cerr << "FileSource::createCacheFile: url " - << m_url.toString().toStdString() << " -> local filename " - << filepath.toStdString() << std::endl; + DEBUG << "FileSource::createCacheFile: url " + << m_url.toString() << " -> local filename " + << filepath << endl; #endif m_localFilename = filepath;