summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavol Babincak <scroolik@gmail.com>2012-04-23 22:09:01 (GMT)
committerRemko Tronçon <git@el-tramo.be>2012-04-24 18:04:58 (GMT)
commitfd990d0154feb63e00b7506b63530376a8bc9f01 (patch)
treed815d8541105374f6320c48aeac52cf0af6e8baa
parent5cf6ef99404a08c0e9d2ed4f6df79375fda11d4a (diff)
downloadswift-contrib-fd990d0154feb63e00b7506b63530376a8bc9f01.zip
swift-contrib-fd990d0154feb63e00b7506b63530376a8bc9f01.tar.bz2
Debug messages print only if logging is enabled
License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
-rw-r--r--Swift/Controllers/Chat/ChatController.cpp8
-rw-r--r--Swift/Controllers/FileTransfer/FileTransferController.cpp5
-rw-r--r--Swift/QtUI/QtChatWindow.cpp9
3 files changed, 11 insertions, 11 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp
index 5602dcd..4352c8b 100644
--- a/Swift/Controllers/Chat/ChatController.cpp
+++ b/Swift/Controllers/Chat/ChatController.cpp
@@ -242,46 +242,46 @@ void ChatController::setOnline(bool online) {
void ChatController::handleNewFileTransferController(FileTransferController* ftc) {
std::string nick = senderDisplayNameFromMessage(ftc->getOtherParty());
std::string ftID = ftc->setChatWindow(chatWindow_, nick);
ftControllers[ftID] = ftc;
}
void ChatController::handleFileTransferCancel(std::string id) {
- std::cout << "handleFileTransferCancel(" << id << ")" << std::endl;
+ SWIFT_LOG(debug) << "handleFileTransferCancel(" << id << ")" << std::endl;
if (ftControllers.find(id) != ftControllers.end()) {
ftControllers[id]->cancel();
} else {
std::cerr << "unknown file transfer UI id" << std::endl;
}
}
void ChatController::handleFileTransferStart(std::string id, std::string description) {
- std::cout << "handleFileTransferStart(" << id << ", " << description << ")" << std::endl;
+ SWIFT_LOG(debug) << "handleFileTransferStart(" << id << ", " << description << ")" << std::endl;
if (ftControllers.find(id) != ftControllers.end()) {
ftControllers[id]->start(description);
} else {
std::cerr << "unknown file transfer UI id" << std::endl;
}
}
void ChatController::handleFileTransferAccept(std::string id, std::string filename) {
- std::cout << "handleFileTransferAccept(" << id << ", " << filename << ")" << std::endl;
+ SWIFT_LOG(debug) "handleFileTransferAccept(" << id << ", " << filename << ")" << std::endl;
if (ftControllers.find(id) != ftControllers.end()) {
ftControllers[id]->accept(filename);
} else {
std::cerr << "unknown file transfer UI id" << std::endl;
}
}
void ChatController::handleSendFileRequest(std::string filename) {
- std::cout << "ChatController::handleSendFileRequest(" << filename << ")" << std::endl;
+ SWIFT_LOG(debug) << "ChatController::handleSendFileRequest(" << filename << ")" << std::endl;
eventStream_->send(boost::make_shared<SendFileUIEvent>(getToJID(), filename));
}
std::string ChatController::senderDisplayNameFromMessage(const JID& from) {
return nickResolver_->jidToNick(from);
}
std::string ChatController::getStatusChangeString(boost::shared_ptr<Presence> presence) {
std::string nick = senderDisplayNameFromMessage(presence->getFrom());
diff --git a/Swift/Controllers/FileTransfer/FileTransferController.cpp b/Swift/Controllers/FileTransfer/FileTransferController.cpp
index afa907d..f1fd19e 100644
--- a/Swift/Controllers/FileTransfer/FileTransferController.cpp
+++ b/Swift/Controllers/FileTransfer/FileTransferController.cpp
@@ -5,18 +5,19 @@
*/
#include "FileTransferController.h"
#include "Swiften/FileTransfer/OutgoingJingleFileTransfer.h"
#include "Swiften/FileTransfer/FileTransferManager.h"
#include <Swiften/FileTransfer/FileReadBytestream.h>
#include <Swiften/Base/boost_bsignals.h>
#include <boost/bind.hpp>
#include "Swift/Controllers/UIInterfaces/ChatWindow.h"
+#include <Swiften/Base/Log.h>
#include <boost/smart_ptr/make_shared.hpp>
namespace Swift {
FileTransferController::FileTransferController(const JID& receipient, const std::string& filename, FileTransferManager* fileTransferManager) :
sending(true), otherParty(receipient), filename(filename), ftManager(fileTransferManager), ftProgressInfo(0), chatWindow(0), currentState(FileTransfer::State::WaitingForStart) {
}
@@ -63,35 +64,35 @@ int FileTransferController::getProgress() const {
boost::uintmax_t FileTransferController::getSize() const {
if (transfer) {
return transfer->fileSizeInBytes;
} else {
return 0;
}
}
void FileTransferController::start(std::string& description) {
- std::cout << "FileTransferController::start" << std::endl;
+ SWIFT_LOG("DEBUG") << "FileTransferController::start" << std::endl;
fileReadStream = boost::make_shared<FileReadBytestream>(boost::filesystem::path(filename));
OutgoingFileTransfer::ref outgoingTransfer = ftManager->createOutgoingFileTransfer(otherParty, boost::filesystem::path(filename), description, fileReadStream);
if (outgoingTransfer) {
ftProgressInfo = new FileTransferProgressInfo(outgoingTransfer->fileSizeInBytes);
ftProgressInfo->onProgressPercentage.connect(boost::bind(&FileTransferController::handleProgressPercentageChange, this, _1));
outgoingTransfer->onStateChange.connect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1));
outgoingTransfer->onProcessedBytes.connect(boost::bind(&FileTransferProgressInfo::setBytesProcessed, ftProgressInfo, _1));
outgoingTransfer->start();
transfer = outgoingTransfer;
} else {
std::cerr << "File transfer not supported!" << std::endl;
}
}
void FileTransferController::accept(std::string& file) {
- std::cout << "FileTransferController::accept" << std::endl;
+ SWIFT_LOG("DEBUG") << "FileTransferController::accept" << std::endl;
IncomingFileTransfer::ref incomingTransfer = boost::dynamic_pointer_cast<IncomingFileTransfer>(transfer);
if (incomingTransfer) {
fileWriteStream = boost::make_shared<FileWriteBytestream>(boost::filesystem::path(file));
ftProgressInfo = new FileTransferProgressInfo(transfer->fileSizeInBytes);
ftProgressInfo->onProgressPercentage.connect(boost::bind(&FileTransferController::handleProgressPercentageChange, this, _1));
transfer->onStateChange.connect(boost::bind(&FileTransferController::handleFileTransferStateChange, this, _1));
transfer->onProcessedBytes.connect(boost::bind(&FileTransferProgressInfo::setBytesProcessed, ftProgressInfo, _1));
incomingTransfer->accept(fileWriteStream);
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp
index 0164ee5..5680996 100644
--- a/Swift/QtUI/QtChatWindow.cpp
+++ b/Swift/QtUI/QtChatWindow.cpp
@@ -40,20 +40,19 @@
#include <QSplitter>
#include <QString>
#include <QTextEdit>
#include <QTime>
#include <QUrl>
#include <QPushButton>
#include <QFileDialog>
#include <QMenu>
#include <Swift/Controllers/Settings/SettingsProvider.h>
-
-#include <QDebug>
+#include <Swiften/Base/Log.h>
namespace Swift {
const QString QtChatWindow::ButtonFileTransferCancel = QString("filetransfer-cancel");
const QString QtChatWindow::ButtonFileTransferSetDescription = QString("filetransfer-setdescription");
const QString QtChatWindow::ButtonFileTransferSendRequest = QString("filetransfer-sendrequest");
const QString QtChatWindow::ButtonFileTransferAcceptRequest = QString("filetransfer-acceptrequest");
const QString QtChatWindow::ButtonMUCInvite = QString("mucinvite");
@@ -525,19 +524,19 @@ std::string formatSize(const boost::uintmax_t bytes) {
QString QtChatWindow::buildChatWindowButton(const QString& name, const QString& id, const QString& arg1, const QString& arg2, const QString& arg3) {
QRegExp regex("[A-Za-z][A-Za-z0-9\\-\\_]+");
Q_ASSERT(regex.exactMatch(id));
QString html = QString("<input id='%2' type='submit' value='%1' onclick='chatwindow.buttonClicked(\"%2\", \"%3\", \"%4\", \"%5\");' />").arg(name).arg(id).arg(arg1).arg(arg2).arg(arg3);
return html;
}
std::string QtChatWindow::addFileTransfer(const std::string& senderName, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes) {
- qDebug() << "addFileTransfer";
+ SWIFT_LOG(debug) << "addFileTransfer" << std::endl;
QString ft_id = QString("ft%1").arg(P2QSTRING(boost::lexical_cast<std::string>(idCounter_++)));
QString htmlString;
QString formattedFileSize = P2QSTRING(formatSize(sizeInBytes));
if (senderIsSelf) {
// outgoing
htmlString = tr("Send file") + ": " + P2QSTRING(filename) + " ( " + formattedFileSize + ") <br/>" +
"<div id='" + ft_id + "'>" +
buildChatWindowButton(tr("Cancel"), ButtonFileTransferCancel, ft_id) +
@@ -611,19 +610,19 @@ void QtChatWindow::handleHTMLButtonClicked(QString id, QString arg1, QString arg
else if (id.startsWith(ButtonMUCInvite)) {
QString roomJID = arg1;
QString password = arg2;
QString elementID = arg3;
eventStream_->send(boost::make_shared<JoinMUCUIEvent>(Q2PSTRING(roomJID), Q2PSTRING(password)));
messageLog_->setMUCInvitationJoined(elementID);
}
else {
- qDebug() << "Unknown HTML button! ( " << id << " )";
+ SWIFT_LOG(debug) << "Unknown HTML button! ( " << Q2PSTRING(id) << " )" << std::endl;
}
}
void QtChatWindow::addErrorMessage(const std::string& errorMessage) {
if (isWidgetSelected()) {
onAllMessagesRead();
}
QString errorMessageHTML(Qt::escape(P2QSTRING(errorMessage)));
@@ -662,19 +661,19 @@ void QtChatWindow::replaceMessage(const std::string& message, const std::string&
messageHTML.replace("\n","<br/>");
QString styleSpanStart = style == "" ? "" : "<span style=\"" + style + "\">";
QString styleSpanEnd = style == "" ? "" : "</span>";
messageHTML = styleSpanStart + messageHTML + styleSpanEnd;
messageLog_->replaceMessage(messageHTML, P2QSTRING(id), B2QDATE(time));
}
else {
- qWarning() << "Trying to replace a message with no id";
+ std::cerr << "Trying to replace a message with no id";
}
}
void QtChatWindow::addPresenceMessage(const std::string& message) {
if (isWidgetSelected()) {
onAllMessagesRead();
}
QString messageHTML(Qt::escape(P2QSTRING(message)));