Unverified Commit b4c071bd authored by Linus Jahn's avatar Linus Jahn 🔌
Browse files

Add command line option to disable XML stream output

This can be very helpful when debugging QML. The command line option is called:
--disable-xml-log. There is no short option.
parent 95f9cff7
......@@ -61,10 +61,11 @@ static const unsigned int KAIDAN_CLIENT_LOOP_INTERVAL = 30;
ClientThread::ClientThread(RosterModel *rosterModel, MessageModel *messageModel,
AvatarFileStorage *avatarStorage, PresenceCache *presenceCache,
Credentials creds, QSettings *settings, Kaidan *kaidan,
QGuiApplication *app, QObject *parent)
QGuiApplication *app, bool enableLogging, QObject *parent)
: QThread(parent), rosterModel(rosterModel), messageModel(messageModel),
avatarStorage(avatarStorage), presenceCache(presenceCache), creds(creds),
settings(settings), connState(ConnectionState::StateNone), kaidan(kaidan)
settings(settings), connState(ConnectionState::StateNone), kaidan(kaidan),
enableLogging(enableLogging)
{
// Set custom thread name
setObjectName("XmppClient");
......@@ -99,7 +100,8 @@ ClientThread::~ClientThread()
delete worker;
delete messageSessionHandler;
delete xmlLogHandler;
if (xmlLogHandler)
delete xmlLogHandler;
}
void ClientThread::run()
......@@ -117,7 +119,8 @@ void ClientThread::run()
rosterManager = new RosterManager(kaidan, client, rosterModel, vCardManager);
presenceHandler = new PresenceHandler(client, presenceCache);
serviceDiscoveryManager = new ServiceDiscoveryManager(client, client->disco());
xmlLogHandler = new XmlLogHandler(client);
if (enableLogging)
xmlLogHandler = new XmlLogHandler(client);
// Register Stanza Extensions
client->registerStanzaExtension(new gloox::Receipt(gloox::Receipt::Request));
......
......@@ -109,7 +109,7 @@ public:
ClientThread(RosterModel *rosterModel, MessageModel *messageModel,
AvatarFileStorage *avatarStorage, PresenceCache *presenceCache,
Credentials creds, QSettings *settings, Kaidan *kaidan,
QGuiApplication *app, QObject *parent = nullptr);
QGuiApplication *app, bool enableLogging = true, QObject *parent = nullptr);
/*
* Will exit the event loop and waits until thread finishes and then
......@@ -249,11 +249,12 @@ private:
ClientWorker *worker;
RosterManager *rosterManager;
MessageSessionHandler *messageSessionHandler;
PresenceCache *presenceCache;
PresenceCache *presenceCache;
PresenceHandler *presenceHandler;
ServiceDiscoveryManager *serviceDiscoveryManager;
VCardManager *vCardManager;
XmlLogHandler *xmlLogHandler;
bool enableLogging;
QSettings *settings;
QMutex mutex;
QTimer workTimer;
......
......@@ -44,7 +44,7 @@
#include "MessageModel.h"
#include "Database.h"
Kaidan::Kaidan(QGuiApplication *app, QObject *parent) : QObject(parent)
Kaidan::Kaidan(QGuiApplication *app, bool enableLogging, QObject *parent) : QObject(parent)
{
//
// Database and components
......@@ -84,7 +84,7 @@ Kaidan::Kaidan(QGuiApplication *app, QObject *parent) : QObject(parent)
// create new client and start thread's main loop (won't connect until requested)
client = new ClientThread(rosterModel, messageModel, avatarStorage, presenceCache, creds,
settings, this, app);
settings, this, app, enableLogging);
client->start();
connect(client, &ClientThread::connectionStateChanged, [=](ConnectionState state) {
......
......@@ -80,7 +80,7 @@ public:
/**
* Constructor
*/
Kaidan(QGuiApplication *app, QObject *parent = 0);
Kaidan(QGuiApplication *app, bool enableLogging = true, QObject *parent = 0);
/**
* Destructor
......
......@@ -75,6 +75,7 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser, QString *err
// add all possible arguments
QCommandLineOption helpOption = parser.addHelpOption();
QCommandLineOption versionOption = parser.addVersionOption();
parser.addOption({"disable-xml-log", "Disable output of full XMPP XML stream."});
// parse arguments
if (!parser.parse(QGuiApplication::arguments())) {
......@@ -170,7 +171,7 @@ int main(int argc, char *argv[])
// Kaidan back-end
//
Kaidan kaidan(&app);
Kaidan kaidan(&app, !parser.isSet("disable-xml-log"));
//
// QML-GUI
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment