#include "messagemodel.h"
#include "network.h"
#include "networkmodel.h"
+#include "quassel.h"
#include "quasselui.h"
#include "signalproxy.h"
#include "util.h"
_messageModel(0),
_messageProcessor(0),
_connectedToCore(false),
- _syncedToCore(false)
+ _syncedToCore(false),
+ _debugLog(&_debugLogBuffer)
{
_signalProxy->synchronize(_ircListHelper);
}
//recvMessage(net, Message::server("", QString("[STATUS] %1").arg(msg)));
}
-void Client::recvMessage(const Message &msg_) {
- Message msg = msg_;
- messageProcessor()->process(msg);
+void Client::recvMessage(const Message &msg) {
+ Message msg_ = msg;
+ messageProcessor()->process(msg_);
}
void Client::setBufferLastSeenMsg(BufferId id, const MsgId &msgId) {
networkModel()->setData(bufferIndex, newName, Qt::DisplayRole);
}
}
+
+void Client::logMessage(QtMsgType type, const char *msg) {
+ QString prefix;
+ switch (type) {
+ case QtDebugMsg:
+ prefix = "Debug";
+ break;
+ case QtWarningMsg:
+ prefix = "Warning";
+ break;
+ case QtCriticalMsg:
+ prefix = "Critical";
+ break;
+ case QtFatalMsg:
+ Quassel::logFatalMessage(msg);
+ return;
+ }
+ instance()->_debugLog << prefix << ": " << msg << "\n";
+ emit instance()->logUpdated();
+}
+
static void setBufferLastSeenMsg(BufferId id, const MsgId &msgId); // this is synced to core and other clients
static void removeBuffer(BufferId id);
+ static void logMessage(QtMsgType type, const char *msg);
+ static inline const QString &debugLog() { return instance()->_debugLogBuffer; }
+
signals:
void sendInput(BufferInfo, QString message);
void requestNetworkStates();
void newClientSyncer(ClientSyncer *);
+ void logUpdated();
+
public slots:
//void selectBuffer(Buffer *);
static AccountId _currentCoreAccount;
+ QString _debugLogBuffer;
+ QTextStream _debugLog;
+
friend class ClientSyncer;
};
out << _buffer << endl;
if(file.isOpen()) file.close();
}
+
+
+void Logger::logMessage(QtMsgType type, const char *msg) {
+ switch (type) {
+ case QtDebugMsg:
+ Logger(Logger::DebugLevel) << msg;
+ break;
+ case QtWarningMsg:
+ Logger(Logger::WarningLevel) << msg;
+ break;
+ case QtCriticalMsg:
+ Logger(Logger::ErrorLevel) << msg;
+ break;
+ case QtFatalMsg:
+ Logger(Logger::ErrorLevel) << msg;
+ Quassel::logFatalMessage(msg);
+ return;
+ }
+}
#include <QTextStream>
class Logger {
- public:
- enum LogLevel {
- DebugLevel,
- InfoLevel,
- WarningLevel,
- ErrorLevel
- };
-
- inline Logger(LogLevel level) : _stream(&_buffer, QIODevice::WriteOnly), _logLevel(level) {}
- ~Logger();
-
- template<typename T>
- inline Logger &operator<<(const T &value) { _stream << value << " "; return *this; }
- inline Logger &operator<<(const QStringList & t) { _stream << t.join(" ") << " "; return *this; }
- inline Logger &operator<<(bool t) { _stream << (t ? "true" : "false") << " "; return *this; }
-
- private:
- void log();
- QTextStream _stream;
- QString _buffer;
- LogLevel _logLevel;
-};
-
-class quDebug : public Logger {
- public:
- inline quDebug() : Logger(Logger::DebugLevel) {}
+public:
+ enum LogLevel {
+ DebugLevel,
+ InfoLevel,
+ WarningLevel,
+ ErrorLevel
+ };
+
+ inline Logger(LogLevel level) : _stream(&_buffer, QIODevice::WriteOnly), _logLevel(level) {}
+ ~Logger();
+
+ static void logMessage(QtMsgType type, const char *msg);
+
+ template<typename T>
+ inline Logger &operator<<(const T &value) { _stream << value << " "; return *this; }
+ inline Logger &operator<<(const QStringList & t) { _stream << t.join(" ") << " "; return *this; }
+ inline Logger &operator<<(bool t) { _stream << (t ? "true" : "false") << " "; return *this; }
+
+private:
+ void log();
+ QTextStream _stream;
+ QString _buffer;
+ LogLevel _logLevel;
};
class quInfo : public Logger {
- public:
- inline quInfo() : Logger(Logger::InfoLevel) {}
-};
-
-class quWarning : public Logger {
- public:
- inline quWarning() : Logger(Logger::WarningLevel) {}
+public:
+ inline quInfo() : Logger(Logger::InfoLevel) {}
};
-class quError : public Logger {
- public:
- inline quError() : Logger(Logger::ErrorLevel) {}
-};
#endif
Quassel::RunMode Quassel::_runMode;
bool Quassel::_initialized = false;
bool Quassel::DEBUG = false;
+QString Quassel::_coreDumpFileName;
Quassel::Quassel() {
Q_INIT_RESOURCE(i18n);
}
}
+void Quassel::logFatalMessage(const char *msg) {
+#ifndef Q_OS_MAC
+ QFile dumpFile(coreDumpFileName());
+ dumpFile.open(QIODevice::WriteOnly);
+ QTextStream dumpStream(&dumpFile);
+#else
+ QTextStream dumpStream(stderr);
+#endif
+
+ dumpStream << "Fatal: " << msg << '\n';
+ dumpStream.flush();
+
+ qInstallMsgHandler(0);
+ abort();
+}
+
void Quassel::handleCrash() {
#ifdef BUILD_CRASHHANDLER
void* callstack[128];
int i, frames = backtrace(callstack, 128);
- QFile dumpFile(QString("Quassel-Crash-%1").arg(QDateTime::currentDateTime().toString("yyyyMMdd-hhmm.log")));
- dumpFile.open(QIODevice::WriteOnly);
+ QFile dumpFile(coreDumpFileName());
+ dumpFile.open(QIODevice::Append);
QTextStream dumpStream(&dumpFile);
+ dumpStream << "Quassel IRC: " << _buildInfo.baseVersion << ' ' << _buildInfo.commitHash << '\n';
+
for (i = 0; i < frames; ++i) {
Dl_info info;
dladdr (callstack[i], &info);
exit(27);
#endif /* BUILD_CRASHHANDLER */
}
+
+const QString &Quassel::coreDumpFileName() {
+ if(_coreDumpFileName.isEmpty())
+ _coreDumpFileName = QString("Quassel-Crash-%1.log").arg(QDateTime::currentDateTime().toString("yyyyMMdd-hhmm"));
+
+ return _coreDumpFileName;
+}
class Quassel {
Q_DECLARE_TR_FUNCTIONS(Quassel)
- public:
- enum RunMode {
- Monolithic,
- ClientOnly,
- CoreOnly
- };
+public:
+ enum RunMode {
+ Monolithic,
+ ClientOnly,
+ CoreOnly
+ };
- struct BuildInfo {
- QString fancyVersionString; // clickable rev
- QString plainVersionString; // no <a> tag
+ struct BuildInfo {
+ QString fancyVersionString; // clickable rev
+ QString plainVersionString; // no <a> tag
- QString baseVersion;
- QString generatedVersion;
- QString commitHash;
- uint commitDate;
- QString buildDate;
- bool isSourceDirty;
- uint protocolVersion;
- uint clientNeedsProtocol;
- uint coreNeedsProtocol;
+ QString baseVersion;
+ QString generatedVersion;
+ QString commitHash;
+ uint commitDate;
+ QString buildDate;
+ bool isSourceDirty;
+ uint protocolVersion;
+ uint clientNeedsProtocol;
+ uint coreNeedsProtocol;
- QString applicationName;
- QString coreApplicationName;
- QString clientApplicationName;
- QString organizationName;
- QString organizationDomain;
- };
+ QString applicationName;
+ QString coreApplicationName;
+ QString clientApplicationName;
+ QString organizationName;
+ QString organizationDomain;
+ };
- void setupBuildInfo(const QString &generated);
+ void setupBuildInfo(const QString &generated);
- virtual ~Quassel();
+ virtual ~Quassel();
- static inline const BuildInfo & buildInfo();
- static inline RunMode runMode();
+ static inline const BuildInfo & buildInfo();
+ static inline RunMode runMode();
- static inline CliParser *cliParser();
- static inline QString optionValue(const QString &option);
- static inline bool isOptionSet(const QString &option);
+ static inline CliParser *cliParser();
+ static inline QString optionValue(const QString &option);
+ static inline bool isOptionSet(const QString &option);
- static bool DEBUG;
+ static const QString &coreDumpFileName();
- protected:
- Quassel();
- virtual bool init();
+ static bool DEBUG;
- inline void setRunMode(RunMode mode);
+ static void logFatalMessage(const char *msg);
+protected:
+ Quassel();
+ virtual bool init();
- private:
- void setupTranslations();
- void registerMetaTypes();
+ inline void setRunMode(RunMode mode);
- static void handleSignal(int signal);
- static void handleCrash();
+private:
+ void setupTranslations();
+ void registerMetaTypes();
- static BuildInfo _buildInfo;
- static CliParser *_cliParser;
- static RunMode _runMode;
- static bool _initialized;
+ static void handleSignal(int signal);
+ static void handleCrash();
+
+ static BuildInfo _buildInfo;
+ static CliParser *_cliParser;
+ static RunMode _runMode;
+ static bool _initialized;
+
+ static QString _coreDumpFileName;
};
const Quassel::BuildInfo & Quassel::buildInfo() { return _buildInfo; }
return db;
if(!openDb()) {
- quWarning() << "Unable to Open Database" << displayName();
- quWarning() << "-" << db.lastError().text();
+ qWarning() << "Unable to Open Database" << displayName();
+ qWarning() << "-" << db.lastError().text();
}
return QSqlDatabase::database("quassel_connection");
return false;
if(installedSchemaVersion() == -1) {
- quError() << "Storage Schema is missing!";
+ qCritical() << "Storage Schema is missing!";
return false;
}
if(installedSchemaVersion() > schemaVersion()) {
- quError() << "Installed Schema is newer then any known Version.";
+ qCritical() << "Installed Schema is newer then any known Version.";
return false;
}
if(installedSchemaVersion() < schemaVersion()) {
- quWarning() << "Installed Schema is not up to date. Upgrading...";
+ qWarning() << "Installed Schema is not up to date. Upgrading...";
if(!upgradeDb())
return false;
}
QFileInfo queryInfo(QString(":/SQL/%1/%2/%3.sql").arg(displayName()).arg(version).arg(queryName));
if(!queryInfo.exists() || !queryInfo.isFile() || !queryInfo.isReadable()) {
- quError() << "Unable to read SQL-Query" << queryName << "for engine" << displayName();
+ qCritical() << "Unable to read SQL-Query" << queryName << "for engine" << displayName();
return QString();
}
Q_UNUSED(settings)
QSqlDatabase db = logDb();
if(!db.isOpen()) {
- quError() << "Unable to setup Logging Backend!";
+ qCritical() << "Unable to setup Logging Backend!";
return false;
}
foreach(QString queryString, setupQueries()) {
QSqlQuery query = db.exec(queryString);
if(!watchQuery(&query)) {
- quError() << "Unable to setup Logging Backend!";
+ qCritical() << "Unable to setup Logging Backend!";
return false;
}
}
foreach(QString queryString, upgradeQueries(ver)) {
QSqlQuery query = db.exec(queryString);
if(!watchQuery(&query)) {
- quError() << "Unable to upgrade Logging Backend!";
+ qCritical() << "Unable to upgrade Logging Backend!";
return false;
}
}
bool AbstractSqlStorage::watchQuery(QSqlQuery *query) {
if(query->lastError().isValid()) {
- quError() << "unhandled Error in QSqlQuery!";
- quError() << " last Query:\n" << query->lastQuery();
- quError() << " executed Query:\n" << query->executedQuery();
- quError() << " bound Values:";
+ qCritical() << "unhandled Error in QSqlQuery!";
+ qCritical() << " last Query:\n" << query->lastQuery();
+ qCritical() << " executed Query:\n" << query->executedQuery();
+ qCritical() << " bound Values:";
QList<QVariant> list = query->boundValues().values();
for (int i = 0; i < list.size(); ++i)
- quError() << i << ": " << list.at(i).toString().toAscii().data();
- quError() << " Error Number:" << query->lastError().number();
- quError() << " Error Message:" << query->lastError().text();
- quError() << " Driver Message:" << query->lastError().driverText();
- quError() << " DB Message:" << query->lastError().databaseText();
+ qCritical() << i << ": " << list.at(i).toString().toAscii().data();
+ qCritical() << " Error Number:" << query->lastError().number();
+ qCritical() << " Error Message:" << query->lastError().text();
+ qCritical() << " Driver Message:" << query->lastError().driverText();
+ qCritical() << " DB Message:" << query->lastError().databaseText();
return false;
}
if(!handlerHash().contains(handler)) {
if(defaultHandler == -1) {
- quWarning() << QString("No such Handler: %1::handle%2").arg(metaObject()->className(), handler);
+ qWarning() << QString("No such Handler: %1::handle%2").arg(metaObject()->className(), handler);
return;
} else {
void *param[] = {0, Q_ARG(QString, member).data(), val0.data(), val1.data(), val2.data(), val3.data(), val4.data(),
registerStorageBackend(new SqliteStorage(this));
if(!_storageBackends.count()) {
- quWarning() << qPrintable(tr("Could not initialize any storage backend! Exiting..."));
- quWarning() << qPrintable(tr("Currently, Quassel only supports SQLite3. You need to build your\n"
+ qWarning() << qPrintable(tr("Could not initialize any storage backend! Exiting..."));
+ qWarning() << qPrintable(tr("Currently, Quassel only supports SQLite3. You need to build your\n"
"Qt library with the sqlite plugin enabled in order for quasselcore\n"
"to work."));
exit(1); // TODO make this less brutal (especially for mono client -> popup)
CoreSettings cs;
if(!(configured = initStorage(cs.storageSettings().toMap()))) {
- quWarning() << "Core is currently not configured! Please connect with a Quassel Client for basic setup.";
+ qWarning() << "Core is currently not configured! Please connect with a Quassel Client for basic setup.";
// try to migrate old settings
QVariantMap old = cs.oldDbSettings().toMap();
QVariantMap newSettings;
newSettings["Backend"] = "SQLite";
if((configured = initStorage(newSettings))) {
- quWarning() << "...but thankfully I found some old settings to migrate!";
+ qWarning() << "...but thankfully I found some old settings to migrate!";
cs.setStorageSettings(newSettings);
}
}
return;
}
if(instance()->sessions.count()) {
- quWarning() << qPrintable(tr("Calling restoreState() even though active sessions exist!"));
+ qWarning() << qPrintable(tr("Calling restoreState() even though active sessions exist!"));
return;
}
CoreSettings s;
if(_storageBackends.contains(backend)) {
storage = _storageBackends[backend];
} else {
- quError() << "Selected storage backend is not available:" << backend;
+ qCritical() << "Selected storage backend is not available:" << backend;
return configured = false;
}
if(!storage->init(dbSettings)) {
if(!setup || !(storage->setup(dbSettings) && storage->init(dbSettings))) {
- quError() << "Could not init storage!";
+ qCritical() << "Could not init storage!";
storage = 0;
return configured = false;
}
}
if(!success) {
- quError() << qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(_server.errorString()));
+ qCritical() << qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(_server.errorString()));
}
return success;
void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) {
if(!msg.contains("MsgType")) {
// Client is way too old, does not even use the current init format
- quWarning() << qPrintable(tr("Antique client trying to connect... refusing."));
+ qWarning() << qPrintable(tr("Antique client trying to connect... refusing."));
socket->close();
return;
}
"This core needs at least client/core protocol version %1.<br>"
"Please consider upgrading your client.").arg(Quassel::buildInfo().coreNeedsProtocol);
SignalProxy::writeDataToDevice(socket, reply);
- quWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("too old, rejecting."));
+ qWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("too old, rejecting."));
socket->close(); return;
}
#ifdef HAVE_SSL
// after we told the client that we are ssl capable we switch to ssl mode
if(supportSsl && msg["UseSsl"].toBool()) {
- quDebug() << qPrintable(tr("Starting TLS for Client:")) << qPrintable(socket->peerAddress().toString());
+ qDebug() << qPrintable(tr("Starting TLS for Client:")) << qPrintable(socket->peerAddress().toString());
connect(sslSocket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(sslErrors(const QList<QSslError> &)));
sslSocket->startServerEncryption();
}
#ifndef QT_NO_COMPRESS
if(supportsCompression && msg["UseCompression"].toBool()) {
socket->setProperty("UseCompression", true);
- quDebug() << "Using compression for Client:" << qPrintable(socket->peerAddress().toString());
+ qDebug() << "Using compression for Client:" << qPrintable(socket->peerAddress().toString());
}
#endif
reply["MsgType"] = "ClientLoginReject";
reply["Error"] = tr("<b>Client not initialized!</b><br>You need to send an init message before trying to login.");
SignalProxy::writeDataToDevice(socket, reply);
- quWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("did not send an init message before trying to login, rejecting."));
+ qWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("did not send an init message before trying to login, rejecting."));
socket->close(); return;
}
if(msg["MsgType"] == "CoreSetupData") {
socket->deleteLater();
} else {
// we have to crawl through the hashes and see if we find a victim to remove
- quDebug() << qPrintable(tr("Non-authed client disconnected. (socket allready destroyed)"));
+ qDebug() << qPrintable(tr("Non-authed client disconnected. (socket allready destroyed)"));
// DO NOT CALL ANY METHODS ON socket!!
socket = static_cast<QTcpSocket *>(sender());
blocksizes.remove(socket);
clientInfo.remove(socket);
if(!sess) {
- quWarning() << qPrintable(tr("Could not initialize session for client:")) << qPrintable(socket->peerAddress().toString());
+ qWarning() << qPrintable(tr("Could not initialize session for client:")) << qPrintable(socket->peerAddress().toString());
socket->close();
}
sess->addClient(socket);
SessionThread *Core::createSession(UserId uid, bool restore) {
if(sessions.contains(uid)) {
- quWarning() << "Calling createSession() when a session for the user already exists!";
+ qWarning() << "Calling createSession() when a session for the user already exists!";
return 0;
}
SessionThread *sess = new SessionThread(uid, restore, this);
void Core::socketError(QAbstractSocket::SocketError err) {
QAbstractSocket *socket = qobject_cast<QAbstractSocket *>(sender());
if(socket && err != QAbstractSocket::RemoteHostClosedError)
- quWarning() << "Core::socketError()" << socket << err << socket->errorString();
+ qWarning() << "Core::socketError()" << socket << err << socket->errorString();
}
#include "coreapplication.h"
#include "core.h"
+#include "logger.h"
CoreApplicationInternal::CoreApplicationInternal()
: _coreCreated(false)
/*****************************************************************************/
-CoreApplication::CoreApplication(int &argc, char **argv) : QCoreApplication(argc, argv), Quassel() {
+CoreApplication::CoreApplication(int &argc, char **argv)
+ : QCoreApplication(argc, argv),
+ Quassel()
+{
setRunMode(Quassel::CoreOnly);
_internal = new CoreApplicationInternal();
+
+ qInstallMsgHandler(Logger::logMessage);
}
CoreApplication::~CoreApplication() {
void CoreNetwork::requestConnect() const {
if(connectionState() != Disconnected) {
- quWarning() << "Requesting connect while already being connected!";
+ qWarning() << "Requesting connect while already being connected!";
return;
}
emit connectRequested(networkId());
void CoreNetwork::requestDisconnect() const {
if(connectionState() == Disconnected) {
- quWarning() << "Requesting disconnect while not being connected!";
+ qWarning() << "Requesting disconnect while not being connected!";
return;
}
emit disconnectRequested(networkId());
foreach(IdentityId id, s.identityIds()) {
Identity *i = new Identity(s.identity(id), this);
if(!i->isValid()) {
- quWarning() << "Invalid identity! Removing...";
+ qWarning() << "Invalid identity! Removing...";
s.removeIdentity(id);
delete i;
continue;
}
if(_identities.contains(i->id())) {
- quWarning() << "Duplicate identity, ignoring!";
+ qWarning() << "Duplicate identity, ignoring!";
delete i;
continue;
}
void CoreSession::connectToNetwork(NetworkId id) {
CoreNetwork *net = network(id);
if(!net) {
- quWarning() << "Connect to unknown network requested! net:" << id << "user:" << user();
+ qWarning() << "Connect to unknown network requested! net:" << id << "user:" << user();
return;
}
void CoreSession::addClient(QIODevice *device) {
if(!device) {
- quError() << "Invoking CoreSession::addClient with a QObject that is not a QIODevice!";
+ qCritical() << "Invoking CoreSession::addClient with a QObject that is not a QIODevice!";
} else {
// if the socket is an orphan, the signalProxy adopts it.
// -> we don't need to care about it anymore
if(conn) {
conn->userInput(bufinfo, msg);
} else {
- quWarning() << "Trying to send to unconnected network:" << msg;
+ qWarning() << "Trying to send to unconnected network:" << msg;
}
}
void CoreSession::identityUpdated(const QVariantMap &data) {
IdentityId id = data.value("identityId", 0).value<IdentityId>();
if(!id.isValid() || !_identities.contains(id)) {
- quWarning() << "Update request for unknown identity received!";
+ qWarning() << "Update request for unknown identity received!";
return;
}
CoreUserSettings s(user());
Core::createNetwork(user(), info);
if(!info.networkId.isValid()) {
- quWarning() << qPrintable(tr("CoreSession::createNetwork(): Got invalid networkId from Core when trying to create network %1!").arg(info.networkName));
+ qWarning() << qPrintable(tr("CoreSession::createNetwork(): Got invalid networkId from Core when trying to create network %1!").arg(info.networkName));
return;
}
signalProxy()->synchronize(net);
emit networkCreated(id);
} else {
- quWarning() << qPrintable(tr("CoreSession::createNetwork(): Trying to create a network that already exists, updating instead!"));
+ qWarning() << qPrintable(tr("CoreSession::createNetwork(): Trying to create a network that already exists, updating instead!"));
_networks[info.networkId]->requestSetNetworkInfo(info);
}
}
void CoreSession::removeBufferRequested(BufferId bufferId) {
BufferInfo bufferInfo = Core::getBufferInfo(user(), bufferId);
if(!bufferInfo.isValid()) {
- quWarning() << "CoreSession::removeBufferRequested(): invalid BufferId:" << bufferId << "for User:" << user();
+ qWarning() << "CoreSession::removeBufferRequested(): invalid BufferId:" << bufferId << "for User:" << user();
return;
}
if(bufferInfo.type() == BufferInfo::StatusBuffer) {
- quWarning() << "CoreSession::removeBufferRequested(): Status Buffers cannot be removed!";
+ qWarning() << "CoreSession::removeBufferRequested(): Status Buffers cannot be removed!";
return;
}
if(bufferInfo.type() == BufferInfo::ChannelBuffer) {
CoreNetwork *net = network(bufferInfo.networkId());
if(!net) {
- quWarning() << "CoreSession::removeBufferRequested(): Received BufferInfo with unknown networkId!";
+ qWarning() << "CoreSession::removeBufferRequested(): Received BufferInfo with unknown networkId!";
return;
}
IrcChannel *chan = net->ircChannel(bufferInfo.bufferName());
if(chan) {
- quWarning() << "CoreSession::removeBufferRequested(): Unable to remove Buffer for joined Channel:" << bufferInfo.bufferName();
+ qWarning() << "CoreSession::removeBufferRequested(): Unable to remove Buffer for joined Channel:" << bufferInfo.bufferName();
return;
}
}
void IrcServerHandler::handleServerMsg(QByteArray msg) {
try {
if(msg.isEmpty()) {
- quWarning() << "Received empty string from server!";
+ qWarning() << "Received empty string from server!";
return;
}
QList<QByteArray> params = msg.split(' ');
if(!trailing.isEmpty()) params << trailing;
if(params.count() < 1) {
- quWarning() << "Received invalid string from server!";
+ qWarning() << "Received invalid string from server!";
return;
}
foo.remove(0, 1);
prefix = foo;
if(params.count() < 1) {
- quWarning() << "Received invalid string from server!";
+ qWarning() << "Received invalid string from server!";
return;
}
foo = serverDecode(params.takeFirst());
uint num = cmd.toUInt();
if(num > 0) {
if(params.count() == 0) {
- quWarning() << "Message received from server violates RFC and is ignored!";
+ qWarning() << "Message received from server violates RFC and is ignored!";
return;
}
params.removeFirst();
else
channel->removeUserMode(ircUser, QString(modes[c]));
} else {
- quWarning() << "Received MODE with too few parameters:" << serverDecode(params);
+ qWarning() << "Received MODE with too few parameters:" << serverDecode(params);
}
paramOffset++;
} else {
if(paramOffset < params.count()) {
value = params[paramOffset];
} else {
- quWarning() << "Received MODE with too few parameters:" << serverDecode(params);
+ qWarning() << "Received MODE with too few parameters:" << serverDecode(params);
}
paramOffset++;
}
IrcUser *ircuser = network()->updateNickFromMask(prefix);
if(!ircuser) {
- quWarning() << "IrcServerHandler::handleNick(): Unknown IrcUser!";
+ qWarning() << "IrcServerHandler::handleNick(): Unknown IrcUser!";
return;
}
QString newnick = serverDecode(params[0]);
IrcUser *ircuser = network()->updateNickFromMask(prefix);
QString channel = serverDecode(params[0]);
if(!ircuser) {
- quWarning() << "IrcServerHandler::handlePart(): Unknown IrcUser!";
+ qWarning() << "IrcServerHandler::handlePart(): Unknown IrcUser!";
return;
}
IrcUser *ircuser = network()->updateNickFromMask(prefix);
if(!ircuser) {
- quWarning() << "IrcServerHandler::handlePrivmsg(): Unknown IrcUser!";
+ qWarning() << "IrcServerHandler::handlePrivmsg(): Unknown IrcUser!";
return;
}
if(params.isEmpty()) {
- quWarning() << "IrcServerHandler::handlePrivmsg(): received PRIVMSG without target or message from:" << prefix;
+ qWarning() << "IrcServerHandler::handlePrivmsg(): received PRIVMSG without target or message from:" << prefix;
return;
}
IrcChannel *channel = network()->ircChannel(channelname);
if(!channel) {
- quWarning() << "IrcServerHandler::handle353(): received unknown target channel:" << channelname;
+ qWarning() << "IrcServerHandler::handle353(): received unknown target channel:" << channelname;
return;
}
bool IrcServerHandler::checkParamCount(const QString &methodName, const QList<QByteArray> ¶ms, int minParams) {
if(params.count() < minParams) {
- quWarning() << qPrintable(methodName) << "requires" << minParams << "parameters but received only" << params.count() << serverDecode(params);
+ qWarning() << qPrintable(methodName) << "requires" << minParams << "parameters but received only" << params.count() << serverDecode(params);
return false;
} else {
return true;
QVariantList serverList = network()->serverList();
Identity *identity = coreSession()->identity(network()->identity());
if(!serverList.count()) {
- quWarning() << "Server list empty, ignoring connect request!";
+ qWarning() << "Server list empty, ignoring connect request!";
return;
}
if(!identity) {
- quWarning() << "Invalid identity configures, ignoring connect request!";
+ qWarning() << "Invalid identity configures, ignoring connect request!";
return;
}
// use a random server?
void NetworkConnection::socketError(QAbstractSocket::SocketError) {
_previousConnectionAttemptFailed = true;
- quWarning() << qPrintable(tr("Could not connect to %1 (%2)").arg(network()->networkName(), socket.errorString()));
+ qWarning() << qPrintable(tr("Could not connect to %1 (%2)").arg(network()->networkName(), socket.errorString()));
emit connectionError(socket.errorString());
emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", tr("Connection failure: %1").arg(socket.errorString()));
network()->emitConnectionError(socket.errorString());
//emit connected(networkId()); initialize first!
Identity *identity = coreSession()->identity(network()->identity());
if(!identity) {
- quError() << "Identity invalid!";
+ qCritical() << "Identity invalid!";
disconnectFromIrc();
return;
}
void NetworkConnection::doAutoReconnect() {
if(connectionState() != Network::Disconnected && connectionState() != Network::Reconnecting) {
- quWarning() << "NetworkConnection::doAutoReconnect(): Cannot reconnect while not being disconnected!";
+ qWarning() << "NetworkConnection::doAutoReconnect(): Cannot reconnect while not being disconnected!";
return;
}
if(_autoReconnectCount > 0) _autoReconnectCount--;
if(withTransaction) {
sync();
if(!logDb().transaction()) {
- quWarning() << "SqliteStorage::removeNetwork(): cannot start transaction. continuing with out rollback support!";
+ qWarning() << "SqliteStorage::removeNetwork(): cannot start transaction. continuing with out rollback support!";
withTransaction = false;
}
}
query->exec();
if(!query->first()) {
watchQuery(query);
- quWarning() << "unable to create BufferInfo for:" << user << networkId << buffer;
+ qWarning() << "unable to create BufferInfo for:" << user << networkId << buffer;
return BufferInfo();
}
}
BufferInfo bufferInfo = BufferInfo(query->value(0).toInt(), networkId, (BufferInfo::Type)query->value(1).toInt(), 0, buffer);
if(query->next()) {
- quError() << "SqliteStorage::getBufferInfo(): received more then one Buffer!";
- quError() << " Query:" << query->lastQuery();
- quError() << " bound Values:";
+ qCritical() << "SqliteStorage::getBufferInfo(): received more then one Buffer!";
+ qCritical() << " Query:" << query->lastQuery();
+ qCritical() << " bound Values:";
QList<QVariant> list = query->boundValues().values();
for (int i = 0; i < list.size(); ++i)
- quError() << i << ":" << list.at(i).toString().toAscii().data();
+ qCritical() << i << ":" << list.at(i).toString().toAscii().data();
Q_ASSERT(false);
}
getPasswordsQuery.exec();
if(!watchQuery(&getPasswordsQuery)) {
- quError() << "unable to migrate to new password format!";
+ qCritical() << "unable to migrate to new password format!";
return false;
}
watchQuery(&setPasswordsQuery);
}
- quDebug() << "successfully migrated passwords!";
+ qDebug() << "successfully migrated passwords!";
return true;
}
_certIsValid = !_cert.isNull() && _cert.isValid() && !_key.isNull();
if(!_certIsValid) {
- quWarning() << "SslServer: SSL Certificate is either missing or has a wrong format!\n"
+ qWarning() << "SslServer: SSL Certificate is either missing or has a wrong format!\n"
<< " Quassel Core will still work, but cannot provide SSL for client connections.\n"
<< " Please see http://quassel-irc.org/faq/cert to learn how to enable SSL support.";
}
coreconnectdlg.cpp
coreinfodlg.cpp
debugconsole.cpp
+ debuglogwidget.cpp
inputwidget.cpp
jumpkeyhandler.cpp
mainwin.cpp
coreconnectdlg.h
coreinfodlg.h
debugconsole.h
+ debuglogwidget.h
inputwidget.h
jumpkeyhandler.h
mainwin.h
coreconnectdlg.ui
coreinfodlg.ui
debugconsole.ui
+ debuglogwidget.ui
inputwidget.ui
msgprocessorstatuswidget.ui
nicklistwidget.ui
#include "clientbacklogmanager.h"
#include "coreinfodlg.h"
#include "coreconnectdlg.h"
+#include "debuglogwidget.h"
#include "iconloader.h"
#include "inputwidget.h"
#include "inputline.h"
qApp, SLOT(aboutQt())));
coll->addAction("DebugNetworkModel", new Action(SmallIcon("tools-report-bug"), tr("Debug &NetworkModel"), coll,
this, SLOT(on_actionDebugNetworkModel_triggered())));
+ coll->addAction("DebugLog", new Action(SmallIcon("tools-report-bug"), tr("Debug &Log"), coll,
+ this, SLOT(on_actionDebugLog_triggered())));
}
void MainWin::setupMenus() {
_helpMenu->addSeparator();
_helpDebugMenu = _helpMenu->addMenu(SmallIcon("tools-report-bug"), tr("Debug"));
_helpDebugMenu->addAction(coll->action("DebugNetworkModel"));
+ _helpDebugMenu->addAction(coll->action("DebugLog"));
}
void MainWin::setupBufferWidget() {
view->show();
}
+void MainWin::on_actionDebugLog_triggered() {
+ DebugLogWidget *logWidget = new DebugLogWidget(0);
+ logWidget->show();
+}
+
void MainWin::saveStateToSession(const QString &sessionId) {
return;
SessionSettings s(sessionId);
void on_actionManageViews_triggered();
void on_actionLockDockPositions_toggled(bool lock);
void on_actionDebugNetworkModel_triggered();
+ void on_actionDebugLog_triggered();
void clientNetworkCreated(NetworkId);
void clientNetworkRemoved(NetworkId);
#include "qtui.h"
#include "sessionsettings.h"
-QtUiApplication::QtUiApplication(int &argc, char **argv) : QApplication(argc, argv), Quassel() {
+
+// void myMessageOutput(QtMsgType type, const char *msg) {
+// Client::debugLog() << "Debug:" << msg << '\n';
+// return;
+// // switch (type) {
+// // case QtDebugMsg:
+// // break;
+// // case QtWarningMsg:
+// // fprintf(stderr, "Warning: %s\n", msg);
+// // break;
+// // case QtCriticalMsg:
+// // fprintf(stderr, "Critical: %s\n", msg);
+// // break;
+// // case QtFatalMsg:
+// // fprintf(stderr, "Fatal: %s\n", msg);
+// // abort();
+// // }
+// }
+
+QtUiApplication::QtUiApplication(int &argc, char **argv)
+ : QApplication(argc, argv), Quassel()
+{
setRunMode(Quassel::ClientOnly);
// put client-only arguments here
CliParser *parser = Quassel::cliParser();
parser->addSwitch("debugbufferswitches",0,"Enables debugging for bufferswitches");
parser->addSwitch("debugmodel",0,"Enables debugging for models");
+
+ qInstallMsgHandler(Client::logMessage);
}
bool QtUiApplication::init() {
s.cleanup();
}
}
+
+
class QtUiApplication : public QApplication, public Quassel {
Q_OBJECT
- public:
- QtUiApplication(int &, char **);
- ~QtUiApplication();
- virtual bool init();
-
- void resumeSessionIfPossible();
- virtual void saveState(QSessionManager & manager);
-
- signals:
- void saveStateToSession(const QString &sessionId);
- void saveStateToSessionSettings(SessionSettings &s); // FIXME refs in signals won't probably work
- void resumeFromSession(const QString sessionId);
- void resumeFromSessionSettings(SessionSettings &s);
-
+ public:
+ QtUiApplication(int &, char **);
+ ~QtUiApplication();
+ virtual bool init();
+
+ void resumeSessionIfPossible();
+ virtual void saveState(QSessionManager & manager);
+
+signals:
+ void saveStateToSession(const QString &sessionId);
+ void saveStateToSessionSettings(SessionSettings &s); // FIXME refs in signals won't probably work
+ void resumeFromSession(const QString sessionId);
+ void resumeFromSessionSettings(SessionSettings &s);
};
#endif