summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'daemon')
-rw-r--r--daemon/appmanager.cpp32
-rw-r--r--daemon/appmanager.h4
-rw-r--r--daemon/appmsgmanager.cpp52
-rw-r--r--daemon/appmsgmanager.h2
-rw-r--r--daemon/bankmanager.cpp77
-rw-r--r--daemon/bankmanager.h2
-rw-r--r--daemon/daemon.cpp34
-rw-r--r--daemon/daemon.pro24
-rw-r--r--daemon/datalogmanager.cpp12
-rw-r--r--daemon/datalogmanager.h2
-rw-r--r--daemon/dbusconnector.cpp17
-rw-r--r--daemon/dbusconnector.h4
-rw-r--r--daemon/jskitmanager.cpp33
-rw-r--r--daemon/jskitmanager.h2
-rw-r--r--daemon/jskitobjects.cpp125
-rw-r--r--daemon/jskitobjects.h8
-rw-r--r--daemon/manager.cpp52
-rw-r--r--daemon/manager.h9
-rw-r--r--daemon/musicmanager.cpp29
-rw-r--r--daemon/musicmanager.h2
-rw-r--r--daemon/notificationmanager.cpp24
-rw-r--r--daemon/notificationmanager.h4
-rw-r--r--daemon/packer.cpp6
-rw-r--r--daemon/packer.h4
-rw-r--r--daemon/unpacker.cpp2
-rw-r--r--daemon/unpacker.h4
-rw-r--r--daemon/uploadmanager.cpp49
-rw-r--r--daemon/uploadmanager.h2
-rw-r--r--daemon/voicecallhandler.cpp28
-rw-r--r--daemon/voicecallhandler.h4
-rw-r--r--daemon/voicecallmanager.cpp8
-rw-r--r--daemon/voicecallmanager.h4
-rw-r--r--daemon/watchconnector.cpp78
-rw-r--r--daemon/watchconnector.h4
34 files changed, 361 insertions, 382 deletions
diff --git a/daemon/appmanager.cpp b/daemon/appmanager.cpp
index 8745160..c10cf22 100644
--- a/daemon/appmanager.cpp
+++ b/daemon/appmanager.cpp
@@ -17,7 +17,7 @@ struct ResourceEntry {
}
AppManager::AppManager(QObject *parent)
- : QObject(parent),
+ : QObject(parent), l(metaObject()->className()),
_watcher(new QFileSystemWatcher(this))
{
connect(_watcher, &QFileSystemWatcher::directoryChanged,
@@ -29,7 +29,7 @@ AppManager::AppManager(QObject *parent)
logger()->warn() << "could not create dir" << dataDir.absoluteFilePath("apps");
}
}
- logger()->debug() << "install apps in" << dataDir.absoluteFilePath("apps");
+ qCDebug(l) << "install apps in" << dataDir.absoluteFilePath("apps");
rescan();
}
@@ -73,9 +73,9 @@ void AppManager::rescan()
Q_FOREACH(const QString &path, appPaths()) {
QDir dir(path);
_watcher->addPath(dir.absolutePath());
- logger()->debug() << "scanning dir" << dir.absolutePath();
+ qCDebug(l) << "scanning dir" << dir.absolutePath();
QStringList entries = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable | QDir::Executable);
- logger()->debug() << "scanning dir results" << entries;
+ qCDebug(l) << "scanning dir results" << entries;
Q_FOREACH(const QString &path, entries) {
QString appPath = dir.absoluteFilePath(path);
_watcher->addPath(appPath);
@@ -86,22 +86,22 @@ void AppManager::rescan()
}
}
- logger()->debug() << "now watching" << _watcher->directories() << _watcher->files();
+ qCDebug(l) << "now watching" << _watcher->directories() << _watcher->files();
emit appsChanged();
}
void AppManager::scanApp(const QString &path)
{
- logger()->debug() << "scanning app" << path;
+ qCDebug(l) << "scanning app" << path;
QDir appDir(path);
if (!appDir.isReadable()) {
- logger()->warn() << "app" << appDir.absolutePath() << "is not readable";
+ qCWarning(l) << "app" << appDir.absolutePath() << "is not readable";
return;
}
QFile appInfoFile(path + "/appinfo.json");
if (!appInfoFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
- logger()->warn() << "cannot open app info file" << appInfoFile.fileName() << ":"
+ qCWarning(l) << "cannot open app info file" << appInfoFile.fileName() << ":"
<< appInfoFile.errorString();
return;
}
@@ -109,7 +109,7 @@ void AppManager::scanApp(const QString &path)
QJsonParseError parseError;
QJsonDocument doc = QJsonDocument::fromJson(appInfoFile.readAll(), &parseError);
if (parseError.error != QJsonParseError::NoError) {
- logger()->warn() << "cannot parse app info file" << appInfoFile.fileName() << ":"
+ qCWarning(l) << "cannot parse app info file" << appInfoFile.fileName() << ":"
<< parseError.errorString();
return;
}
@@ -181,7 +181,7 @@ void AppManager::scanApp(const QString &path)
info.setPath(path);
if (info.uuid().isNull() || info.shortName().isEmpty()) {
- logger()->warn() << "invalid or empty uuid/name in" << appInfoFile.fileName();
+ qCWarning(l) << "invalid or empty uuid/name in" << appInfoFile.fileName();
return;
}
@@ -189,14 +189,14 @@ void AppManager::scanApp(const QString &path)
_names.insert(info.shortName(), info.uuid());
const char *type = info.isWatchface() ? "watchface" : "app";
- logger()->debug() << "found installed" << type << info.shortName() << info.versionLabel() << "with uuid" << info.uuid().toString();
+ qCDebug(l) << "found installed" << type << info.shortName() << info.versionLabel() << "with uuid" << info.uuid().toString();
}
QByteArray AppManager::extractFromResourcePack(const QString &file, int wanted_id) const
{
QFile f(file);
if (!f.open(QIODevice::ReadOnly)) {
- logger()->warn() << "cannot open resource file" << f.fileName();
+ qCWarning(l) << "cannot open resource file" << f.fileName();
return QByteArray();
}
@@ -207,7 +207,7 @@ QByteArray AppManager::extractFromResourcePack(const QString &file, int wanted_i
u.readLE<quint32>(); // crc for entire file
u.readLE<quint32>(); // timestamp
- logger()->debug() << "reading" << num_files << "resources from" << file;
+ qCDebug(l) << "reading" << num_files << "resources from" << file;
QList<ResourceEntry> table;
@@ -219,7 +219,7 @@ QByteArray AppManager::extractFromResourcePack(const QString &file, int wanted_i
e.crc = u.readLE<quint32>();
if (u.bad()) {
- logger()->warn() << "short read on resource file";
+ qCWarning(l) << "short read on resource file";
return QByteArray();
}
@@ -227,7 +227,7 @@ QByteArray AppManager::extractFromResourcePack(const QString &file, int wanted_i
}
if (wanted_id >= table.size()) {
- logger()->warn() << "specified resource does not exist";
+ qCWarning(l) << "specified resource does not exist";
return QByteArray();
}
@@ -241,7 +241,7 @@ QByteArray AppManager::extractFromResourcePack(const QString &file, int wanted_i
crc.addData(res);
if (crc.result() != e.crc) {
- logger()->warn() << "CRC failure in resource" << e.index << "on file" << file;
+ qCWarning(l) << "CRC failure in resource" << e.index << "on file" << file;
return QByteArray();
}
diff --git a/daemon/appmanager.h b/daemon/appmanager.h
index d5e5ba1..e96ffe5 100644
--- a/daemon/appmanager.h
+++ b/daemon/appmanager.h
@@ -5,13 +5,13 @@
#include <QHash>
#include <QUuid>
#include <QFileSystemWatcher>
-#include <Log4Qt/Logger>
+#include <QLoggingCategory>
#include "appinfo.h"
class AppManager : public QObject
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
public:
explicit AppManager(QObject *parent = 0);
diff --git a/daemon/appmsgmanager.cpp b/daemon/appmsgmanager.cpp
index eda1eb4..1a4a424 100644
--- a/daemon/appmsgmanager.cpp
+++ b/daemon/appmsgmanager.cpp
@@ -7,7 +7,8 @@
// TODO D-Bus server for non JS kit apps!!!!
AppMsgManager::AppMsgManager(AppManager *apps, WatchConnector *watch, QObject *parent)
- : QObject(parent), apps(apps), watch(watch), _lastTransactionId(0), _timeout(new QTimer(this))
+ : QObject(parent), l(metaObject()->className()), apps(apps),
+ watch(watch), _lastTransactionId(0), _timeout(new QTimer(this))
{
connect(watch, &WatchConnector::connectedChanged,
this, &AppMsgManager::handleWatchConnectedChanged);
@@ -45,7 +46,7 @@ AppMsgManager::AppMsgManager(AppManager *apps, WatchConnector *watch, QObject *p
handleAckMessage(data, false);
break;
default:
- logger()->warn() << "Unknown application message type:" << int(data.at(0));
+ qCWarning(l) << "Unknown application message type:" << int(data.at(0));
break;
}
@@ -62,7 +63,7 @@ void AppMsgManager::send(const QUuid &uuid, const QVariantMap &data, const std::
trans.ackCallback = ackCallback;
trans.nackCallback = nackCallback;
- logger()->debug() << "Queueing appmsg" << trans.transactionId << "to" << trans.uuid
+ qCDebug(l) << "Queueing appmsg" << trans.transactionId << "to" << trans.uuid
<< "with dict" << trans.dict;
_pending.enqueue(trans);
@@ -104,7 +105,7 @@ void AppMsgManager::launchApp(const QUuid &uuid)
WatchConnector::Dict dict;
dict.insert(1, WatchConnector::launcherSTARTED);
- logger()->debug() << "Sending message to launcher" << uuid << dict;
+ qCDebug(l) << "Sending message to launcher" << uuid << dict;
QByteArray msg = buildPushMessage(++_lastTransactionId, uuid, dict);
watch->sendMessage(WatchConnector::watchLAUNCHER, msg);
@@ -115,7 +116,7 @@ void AppMsgManager::closeApp(const QUuid &uuid)
WatchConnector::Dict dict;
dict.insert(1, WatchConnector::launcherSTOPPED);
- logger()->debug() << "Sending message to launcher" << uuid << dict;
+ qCDebug(l) << "Sending message to launcher" << uuid << dict;
QByteArray msg = buildPushMessage(++_lastTransactionId, uuid, dict);
watch->sendMessage(WatchConnector::watchLAUNCHER, msg);
@@ -125,7 +126,7 @@ WatchConnector::Dict AppMsgManager::mapAppKeys(const QUuid &uuid, const QVariant
{
AppInfo info = apps->info(uuid);
if (info.uuid() != uuid) {
- logger()->warn() << "Unknown app GUID while sending message:" << uuid;
+ qCWarning(l) << "Unknown app GUID while sending message:" << uuid;
}
WatchConnector::Dict d;
@@ -141,7 +142,7 @@ WatchConnector::Dict AppMsgManager::mapAppKeys(const QUuid &uuid, const QVariant
if (ok) {
d.insert(num, it.value());
} else {
- logger()->warn() << "Unknown appKey" << it.key() << "for app with GUID" << uuid;
+ qCWarning(l) << "Unknown appKey" << it.key() << "for app with GUID" << uuid;
}
}
}
@@ -153,7 +154,7 @@ QVariantMap AppMsgManager::mapAppKeys(const QUuid &uuid, const WatchConnector::D
{
AppInfo info = apps->info(uuid);
if (info.uuid() != uuid) {
- logger()->warn() << "Unknown app GUID while sending message:" << uuid;
+ qCWarning(l) << "Unknown app GUID while sending message:" << uuid;
}
QVariantMap data;
@@ -162,7 +163,7 @@ QVariantMap AppMsgManager::mapAppKeys(const QUuid &uuid, const WatchConnector::D
if (info.hasAppKeyValue(it.key())) {
data.insert(info.appKeyForValue(it.key()), it.value());
} else {
- logger()->warn() << "Unknown appKey value" << it.key() << "for app with GUID" << uuid;
+ qCWarning(l) << "Unknown appKey value" << it.key() << "for app with GUID" << uuid;
data.insert(QString::number(it.key()), it.value());
}
}
@@ -174,6 +175,7 @@ bool AppMsgManager::unpackPushMessage(const QByteArray &msg, quint8 *transaction
{
Unpacker u(msg);
quint8 code = u.read<quint8>();
+ Q_UNUSED(code);
Q_ASSERT(code == WatchConnector::appmsgPUSH);
*transaction = u.read<quint8>();
@@ -225,29 +227,29 @@ void AppMsgManager::handleLauncherPushMessage(const QByteArray &data)
// Failed to parse!
// Since we're the only one handling this endpoint,
// all messages must be accepted
- logger()->warn() << "Failed to parser LAUNCHER PUSH message";
+ qCWarning(l) << "Failed to parser LAUNCHER PUSH message";
return;
}
if (!dict.contains(1)) {
- logger()->warn() << "LAUNCHER message has no item in dict";
+ qCWarning(l) << "LAUNCHER message has no item in dict";
return;
}
switch (dict.value(1).toInt()) {
case WatchConnector::launcherSTARTED:
- logger()->debug() << "App starting in watch:" << uuid;
+ qCDebug(l) << "App starting in watch:" << uuid;
this->watch->sendMessage(WatchConnector::watchLAUNCHER,
buildAckMessage(transaction));
emit appStarted(uuid);
break;
case WatchConnector::launcherSTOPPED:
- logger()->debug() << "App stopping in watch:" << uuid;
+ qCDebug(l) << "App stopping in watch:" << uuid;
this->watch->sendMessage(WatchConnector::watchLAUNCHER,
buildAckMessage(transaction));
emit appStopped(uuid);
break;
default:
- logger()->warn() << "LAUNCHER pushed unknown message:" << uuid << dict;
+ qCWarning(l) << "LAUNCHER pushed unknown message:" << uuid << dict;
this->watch->sendMessage(WatchConnector::watchLAUNCHER,
buildNackMessage(transaction));
break;
@@ -261,16 +263,16 @@ void AppMsgManager::handlePushMessage(const QByteArray &data)
WatchConnector::Dict dict;
if (!unpackPushMessage(data, &transaction, &uuid, &dict)) {
- logger()->warn() << "Failed to parse APP_MSG PUSH";
+ qCWarning(l) << "Failed to parse APP_MSG PUSH";
watch->sendMessage(WatchConnector::watchAPPLICATION_MESSAGE,
buildNackMessage(transaction));
return;
}
- logger()->debug() << "Received appmsg PUSH from" << uuid << "with" << dict;
+ qCDebug(l) << "Received appmsg PUSH from" << uuid << "with" << dict;
QVariantMap msg = mapAppKeys(uuid, dict);
- logger()->debug() << "Mapped dict" << msg;
+ qCDebug(l) << "Mapped dict" << msg;
bool result;
@@ -283,11 +285,11 @@ void AppMsgManager::handlePushMessage(const QByteArray &data)
}
if (result) {
- logger()->debug() << "ACKing transaction" << transaction;
+ qCDebug(l) << "ACKing transaction" << transaction;
watch->sendMessage(WatchConnector::watchAPPLICATION_MESSAGE,
buildAckMessage(transaction));
} else {
- logger()->info() << "NACKing transaction" << transaction;
+ qCDebug(l) << "NACKing transaction" << transaction;
watch->sendMessage(WatchConnector::watchAPPLICATION_MESSAGE,
buildNackMessage(transaction));
}
@@ -296,26 +298,26 @@ void AppMsgManager::handlePushMessage(const QByteArray &data)
void AppMsgManager::handleAckMessage(const QByteArray &data, bool ack)
{
if (data.size() < 2) {
- logger()->warn() << "invalid ack/nack message size";
+ qCWarning(l) << "invalid ack/nack message size";
return;
}
- const quint8 type = data[0];
+ const quint8 type = data[0]; Q_UNUSED(type);
const quint8 recv_transaction = data[1];
Q_ASSERT(type == WatchConnector::appmsgACK || type == WatchConnector::appmsgNACK);
if (_pending.empty()) {
- logger()->warn() << "received an ack/nack for transaction" << recv_transaction << "but no transaction is pending";
+ qCWarning(l) << "received an ack/nack for transaction" << recv_transaction << "but no transaction is pending";
return;
}
PendingTransaction &trans = _pending.head();
if (trans.transactionId != recv_transaction) {
- logger()->warn() << "received an ack/nack but for the wrong transaction";
+ qCWarning(l) << "received an ack/nack but for the wrong transaction";
}
- logger()->debug() << "Got " << (ack ? "ACK" : "NACK") << " to transaction" << trans.transactionId;
+ qCDebug(l) << "Got " << (ack ? "ACK" : "NACK") << " to transaction" << trans.transactionId;
_timeout->stop();
@@ -351,7 +353,7 @@ void AppMsgManager::handleTimeout()
Q_ASSERT(!_pending.empty());
PendingTransaction trans = _pending.dequeue();
- logger()->warn() << "timeout on appmsg transaction" << trans.transactionId;
+ qCWarning(l) << "timeout on appmsg transaction" << trans.transactionId;
if (trans.nackCallback) {
trans.nackCallback();
diff --git a/daemon/appmsgmanager.h b/daemon/appmsgmanager.h
index e52c544..0a3acba 100644
--- a/daemon/appmsgmanager.h
+++ b/daemon/appmsgmanager.h
@@ -11,7 +11,7 @@
class AppMsgManager : public QObject
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
public:
explicit AppMsgManager(AppManager *apps, WatchConnector *watch, QObject *parent);
diff --git a/daemon/bankmanager.cpp b/daemon/bankmanager.cpp
index 7bc7f91..f0aa68b 100644
--- a/daemon/bankmanager.cpp
+++ b/daemon/bankmanager.cpp
@@ -7,17 +7,17 @@
#if 0
// TODO -- This is how language files seems to be installed.
if (slot == -4) {
- logger()->debug() << "starting lang install";
+ qCDebug(l) << "starting lang install";
QFile *pbl = new QFile(QDir::home().absoluteFilePath("es.pbl"));
if (!pbl->open(QIODevice::ReadOnly)) {
- logger()->warn() << "Failed to open pbl";
+ qCWarning(l) << "Failed to open pbl";
return false;
}
upload->uploadFile("lang", pbl, [this]() {
- logger()->debug() << "success";
+ qCDebug(l) << "success";
}, [this](int code) {
- logger()->warn() << "Some error" << code;
+ qCWarning(l) << "Some error" << code;
});
return true;
@@ -25,7 +25,8 @@ if (slot == -4) {
#endif
BankManager::BankManager(WatchConnector *watch, UploadManager *upload, AppManager *apps, QObject *parent) :
- QObject(parent), watch(watch), upload(upload), apps(apps), _refresh(new QTimer(this))
+ QObject(parent), l(metaObject()->className()),
+ watch(watch), upload(upload), apps(apps), _refresh(new QTimer(this))
{
connect(watch, &WatchConnector::connectedChanged,
this, &BankManager::handleWatchConnected);
@@ -55,43 +56,43 @@ bool BankManager::uploadApp(const QUuid &uuid, int slot)
{
AppInfo info = apps->info(uuid);
if (info.uuid() != uuid) {
- logger()->warn() << "uuid" << uuid << "is not installed";
+ qCWarning(l) << "uuid" << uuid << "is not installed";
return false;
}
if (slot == -1) {
slot = findUnusedSlot();
if (slot == -1) {
- logger()->warn() << "no free slots!";
+ qCWarning(l) << "no free slots!";
return false;
}
}
if (slot < 0 || slot > _slots.size()) {
- logger()->warn() << "invalid slot index";
+ qCWarning(l) << "invalid slot index";
return false;
}
if (_slots[slot].used) {
- logger()->warn() << "slot in use";
+ qCWarning(l) << "slot in use";
return false;
}
QDir appDir(info.path());
- logger()->debug() << "about to install app from" << appDir.absolutePath() << "into slot" << slot;
+ qCDebug(l) << "about to install app from" << appDir.absolutePath() << "into slot" << slot;
QFile *binaryFile = new QFile(appDir.absoluteFilePath("pebble-app.bin"), this);
if (!binaryFile->open(QIODevice::ReadOnly)) {
- logger()->warn() << "failed to open" << binaryFile->fileName() << ":" << binaryFile->errorString();
+ qCWarning(l) << "failed to open" << binaryFile->fileName() << ":" << binaryFile->errorString();
delete binaryFile;
return false;
}
- logger()->debug() << "binary file size is" << binaryFile->size();
+ qCDebug(l) << "binary file size is" << binaryFile->size();
QFile *resourceFile = 0;
if (appDir.exists("app_resources.pbpack")) {
resourceFile = new QFile(appDir.absoluteFilePath("app_resources.pbpack"), this);
if (!resourceFile->open(QIODevice::ReadOnly)) {
- logger()->warn() << "failed to open" << resourceFile->fileName() << ":" << resourceFile->errorString();
+ qCWarning(l) << "failed to open" << resourceFile->fileName() << ":" << resourceFile->errorString();
delete resourceFile;
return false;
}
@@ -104,27 +105,27 @@ bool BankManager::uploadApp(const QUuid &uuid, int slot)
upload->uploadAppBinary(slot, binaryFile,
[this, binaryFile, resourceFile, slot]() {
- logger()->debug() << "app binary upload succesful";
+ qCDebug(l) << "app binary upload succesful";
delete binaryFile;
// Proceed to upload the resource file
if (resourceFile) {
upload->uploadAppResources(slot, resourceFile,
[this, resourceFile, slot]() {
- logger()->debug() << "app resources upload succesful";
+ qCDebug(l) << "app resources upload succesful";
delete resourceFile;
// Upload succesful
// Tell the watch to reload the slot
refreshWatchApp(slot, [this]() {
- logger()->debug() << "app refresh succesful";
+ qCDebug(l) << "app refresh succesful";
_refresh->start();
}, [this](int code) {
- logger()->warn() << "app refresh failed" << code;
+ qCWarning(l) << "app refresh failed" << code;
_refresh->start();
});
}, [this, resourceFile](int code) {
- logger()->warn() << "app resources upload failed" << code;
+ qCWarning(l) << "app resources upload failed" << code;
delete resourceFile;
_refresh->start();
@@ -134,15 +135,15 @@ bool BankManager::uploadApp(const QUuid &uuid, int slot)
// No resource file
// Tell the watch to reload the slot
refreshWatchApp(slot, [this]() {
- logger()->debug() << "app refresh succesful";
+ qCDebug(l) << "app refresh succesful";
_refresh->start();
}, [this](int code) {
- logger()->warn() << "app refresh failed" << code;
+ qCWarning(l) << "app refresh failed" << code;
_refresh->start();
});
}
}, [this, binaryFile, resourceFile](int code) {
- logger()->warn() << "app binary upload failed" << code;
+ qCWarning(l) << "app binary upload failed" << code;
delete binaryFile;
delete resourceFile;
@@ -155,15 +156,15 @@ bool BankManager::uploadApp(const QUuid &uuid, int slot)
bool BankManager::unloadApp(int slot)
{
if (slot < 0 || slot > _slots.size()) {
- logger()->warn() << "invalid slot index";
+ qCWarning(l) << "invalid slot index";
return false;
}
if (!_slots[slot].used) {
- logger()->warn() << "slot is empty";
+ qCWarning(l) << "slot is empty";
return false;
}
- logger()->debug() << "going to unload app" << _slots[slot].name << "in slot" << slot;
+ qCDebug(l) << "going to unload app" << _slots[slot].name << "in slot" << slot;
int installId = _slots[slot].id;
@@ -184,10 +185,10 @@ bool BankManager::unloadApp(int slot)
uint result = u.read<quint32>();
switch (result) {
case Success: /* Success */
- logger()->debug() << "sucessfully unloaded app";
+ qCDebug(l) << "sucessfully unloaded app";
break;
default:
- logger()->warn() << "could not unload app. result code:" << result;
+ qCWarning(l) << "could not unload app. result code:" << result;
break;
}
@@ -201,7 +202,7 @@ bool BankManager::unloadApp(int slot)
void BankManager::refresh()
{
- logger()->debug() << "refreshing bank status";
+ qCDebug(l) << "refreshing bank status";
watch->sendMessage(WatchConnector::watchAPP_MANAGER,
QByteArray(1, WatchConnector::appmgrGET_APPBANK_STATUS),
@@ -211,7 +212,7 @@ void BankManager::refresh()
}
if (data.size() < 9) {
- logger()->warn() << "invalid getAppbankStatus response";
+ qCWarning(l) << "invalid getAppbankStatus response";
return true;
}
@@ -222,7 +223,7 @@ void BankManager::refresh()
unsigned int num_banks = u.read<quint32>();
unsigned int apps_installed = u.read<quint32>();
- logger()->debug() << "Bank status:" << apps_installed << "/" << num_banks;
+ qCDebug(l) << "Bank status:" << apps_installed << "/" << num_banks;
_slots.resize(num_banks);
for (unsigned int i = 0; i < num_banks; i++) {
@@ -244,12 +245,12 @@ void BankManager::refresh()
unsigned short version = u.read<quint16>();
if (index < 0 || index >= _slots.size()) {
- logger()->warn() << "Invalid slot index" << index;
+ qCWarning(l) << "Invalid slot index" << index;
continue;
}
if (u.bad()) {
- logger()->warn() << "short read";
+ qCWarning(l) << "short read";
return true;
}
@@ -264,7 +265,7 @@ void BankManager::refresh()
QUuid uuid = info.uuid();
_slots[index].uuid = uuid;
- logger()->debug() << index << id << name << company << flags << version << uuid;
+ qCDebug(l) << index << id << name << company << flags << version << uuid;
}
emit this->slotsChanged();
@@ -332,10 +333,10 @@ void BankManager::getAppbankUuids(const function<void(const QList<QUuid> &)>& ca
if (data.at(0) != WatchConnector::appmgrGET_APPBANK_UUIDS) {
return false;
}
- logger()->debug() << "getAppbankUuids response" << data.toHex();
+ qCDebug(l) << "getAppbankUuids response" << data.toHex();
if (data.size() < 5) {
- logger()->warn() << "invalid getAppbankUuids response";
+ qCWarning(l) << "invalid getAppbankUuids response";
return true;
}
@@ -345,24 +346,24 @@ void BankManager::getAppbankUuids(const function<void(const QList<QUuid> &)>& ca
unsigned int apps_installed = u.read<quint32>();
- logger()->debug() << apps_installed;
+ qCDebug(l) << apps_installed;
QList<QUuid> uuids;
for (unsigned int i = 0; i < apps_installed; i++) {
QUuid uuid = u.readUuid();
- logger()->debug() << uuid.toString();
+ qCDebug(l) << uuid.toString();
if (u.bad()) {
- logger()->warn() << "short read";
+ qCWarning(l) << "short read";
return true;
}
uuids.push_back(uuid);
}
- logger()->debug() << "finished";
+ qCDebug(l) << "finished";
callback(uuids);
diff --git a/daemon/bankmanager.h b/daemon/bankmanager.h
index 871db6b..7532812 100644
--- a/daemon/bankmanager.h
+++ b/daemon/bankmanager.h
@@ -8,7 +8,7 @@
class BankManager : public QObject
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
public:
explicit BankManager(WatchConnector *watch, UploadManager *upload, AppManager *apps, QObject *parent = 0);
diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp
index b745e5c..178f04d 100644
--- a/daemon/daemon.cpp
+++ b/daemon/daemon.cpp
@@ -34,8 +34,7 @@
#include <QFile>
#include <QDir>
#include <QFileInfo>
-#include <Log4Qt/LogManager>
-#include <Log4Qt/PropertyConfigurator>
+#include <QLoggingCategory>
void signalhandler(int sig)
{
@@ -49,34 +48,21 @@ void signalhandler(int sig)
}
}
-void initLogging()
-{
- // Sailfish OS-specific locations for the app settings files and app's own files
- const QString logConfigFilePath(QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).at(0)
- + "pebble/log4qt.conf");
- const QString fallbackLogConfigPath("/usr/share/pebble/log4qt.conf");
-
- const QString& usedConfigFile = QFile::exists(logConfigFilePath) ? logConfigFilePath : fallbackLogConfigPath;
- Log4Qt::PropertyConfigurator::configure(usedConfigFile);
-
- // For capturing qDebug() and console.log() messages
- // Note that console.log() might fail in Sailfish OS device builds. Not sure why, but it seems like
- // console.log() exactly in Sailfish OS device release builds doesn't go through the same qDebug() channel
- Log4Qt::LogManager::setHandleQtMessages(true);
-
- qDebug() << "Using following log config file:" << usedConfigFile;
-}
-
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
app.setApplicationName("pebble"); // Use the same appname as the UI.
- // Init logging should be called after app object creation as initLogging() will examine
- // QCoreApplication for determining the .conf files locations
- initLogging();
+ QStringList filterRules;
+
+ filterRules << (argc > 1 and QString("-d") == argv[0] ?
+ "*.debug=false" : "*.debug=true");
+
+ // Init logging should be called after app object creation
+ QLoggingCategory::setFilterRules(filterRules.join("\n"));
- Log4Qt::Logger::logger(QLatin1String("Main Logger"))->info() << argv[0] << APP_VERSION;
+ QLoggingCategory l("main");
+ qCDebug(l) << argv[0] << APP_VERSION;
Settings settings;
Manager manager(&settings);
diff --git a/daemon/daemon.pro b/daemon/daemon.pro
index 6eea288..1c287d0 100644
--- a/daemon/daemon.pro
+++ b/daemon/daemon.pro
@@ -2,14 +2,11 @@ TARGET = pebbled
CONFIG += console
CONFIG += link_pkgconfig
-QT -= gui
-QT += bluetooth dbus contacts gui qml positioning
+QT += core gui qml bluetooth dbus contacts positioning
PKGCONFIG += mlite5 icu-i18n
CONFIG += c++11
-LIBS += -llog4qt
-
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
SOURCES += \
@@ -54,14 +51,12 @@ HEADERS += \
uploadmanager.h \
stm32crc.h
-OTHER_FILES += \
- ../log4qt-debug.conf \
- ../log4qt-release.conf \
- js/typedarray.js
-
DBUS_ADAPTORS += ../org.pebbled.Watch.xml
-INSTALLS += target systemd confile js
+OTHER_FILES += $$DBUS_ADAPTORS \
+ js/typedarray.js
+
+INSTALLS += target systemd js
target.path = /usr/bin
@@ -71,14 +66,5 @@ systemd.path = /usr/lib/systemd/user
js.files = js/*
js.path = /usr/share/pebble/js
-CONFIG(debug, debug|release) {
- confile.extra = cp $$PWD/../log4qt-debug.conf $$OUT_PWD/../log4qt.conf
-} else {
- confile.extra = cp $$PWD/../log4qt-release.conf $$OUT_PWD/../log4qt.conf
-}
-
-confile.files = $$OUT_PWD/../log4qt.conf
-confile.path = /usr/share/pebble
-
# unnecesary includes, just so QtCreator could find headers... :-(
INCLUDEPATH += $$[QT_HOST_PREFIX]/include/mlite5
diff --git a/daemon/datalogmanager.cpp b/daemon/datalogmanager.cpp
index 8026e15..c3562ef 100644
--- a/daemon/datalogmanager.cpp
+++ b/daemon/datalogmanager.cpp
@@ -2,11 +2,11 @@
#include "unpacker.h"
DataLogManager::DataLogManager(WatchConnector *watch, QObject *parent) :
- QObject(parent), watch(watch)
+ QObject(parent), l(metaObject()->className()), watch(watch)
{
watch->setEndpointHandler(WatchConnector::watchDATA_LOGGING, [this](const QByteArray& data) {
if (data.size() < 2) {
- logger()->warn() << "small data_logging packet";
+ qCWarning(l) << "small data_logging packet";
return false;
}
@@ -15,13 +15,13 @@ DataLogManager::DataLogManager(WatchConnector *watch, QObject *parent) :
switch (command) {
case WatchConnector::datalogOPEN:
- logger()->debug() << "open datalog session" << session;
+ qCDebug(l) << "open datalog session" << session;
return true;
case WatchConnector::datalogCLOSE:
- logger()->debug() << "close datalog session" << session;
+ qCDebug(l) << "close datalog session" << session;
return true;
case WatchConnector::datalogTIMEOUT:
- logger()->debug() << "timeout datalog session" << session;
+ qCDebug(l) << "timeout datalog session" << session;
return true;
case WatchConnector::datalogDATA:
handleDataCommand(session, data.mid(2));
@@ -38,5 +38,5 @@ void DataLogManager::handleDataCommand(int session, const QByteArray &data)
// TODO Seemingly related to analytics, so not important.
- logger()->debug() << "got datalog data" << session << data.size();
+ qCDebug(l) << "got datalog data" << session << data.size();
}
diff --git a/daemon/datalogmanager.h b/daemon/datalogmanager.h
index 47fc948..b36875a 100644
--- a/daemon/datalogmanager.h
+++ b/daemon/datalogmanager.h
@@ -6,7 +6,7 @@
class DataLogManager : public QObject
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
public:
explicit DataLogManager(WatchConnector *watch, QObject *parent = 0);
diff --git a/daemon/dbusconnector.cpp b/daemon/dbusconnector.cpp
index 1f3ffc2..197a12f 100644
--- a/daemon/dbusconnector.cpp
+++ b/daemon/dbusconnector.cpp
@@ -13,9 +13,8 @@
//dbus-send --system --dest=org.bluez --print-reply $devpath org.bluez.Input.Connect
DBusConnector::DBusConnector(QObject *parent) :
- QObject(parent)
-{
-}
+ QObject(parent), l(metaObject()->className())
+{}
bool DBusConnector::findPebble()
{
@@ -25,14 +24,14 @@ bool DBusConnector::findPebble()
QDBusMessage::createMethodCall("org.bluez", "/", "org.bluez.Manager",
"ListAdapters"));
if (not ListAdaptersReply.isValid()) {
- logger()->error() << ListAdaptersReply.error().message();
+ qCCritical(l) << ListAdaptersReply.error().message();
return false;
}
QList<QDBusObjectPath> adapters = ListAdaptersReply.value();
if (adapters.isEmpty()) {
- logger()->debug() << "No BT adapters found";
+ qCDebug(l) << "No BT adapters found";
return false;
}
@@ -40,7 +39,7 @@ bool DBusConnector::findPebble()
QDBusMessage::createMethodCall("org.bluez", adapters[0].path(), "org.bluez.Adapter",
"GetProperties"));
if (not AdapterPropertiesReply.isValid()) {
- logger()->error() << AdapterPropertiesReply.error().message();
+ qCCritical(l) << AdapterPropertiesReply.error().message();
return false;
}
@@ -52,16 +51,16 @@ bool DBusConnector::findPebble()
QDBusMessage::createMethodCall("org.bluez", path.path(), "org.bluez.Device",
"GetProperties"));
if (not DevicePropertiesReply.isValid()) {
- logger()->error() << DevicePropertiesReply.error().message();
+ qCCritical(l) << DevicePropertiesReply.error().message();
continue;
}
const QVariantMap &dict = DevicePropertiesReply.value();
QString tmp = dict["Name"].toString();
- logger()->debug() << "Found BT device:" << tmp;
+ qCDebug(l) << "Found BT device:" << tmp;
if (tmp.startsWith("Pebble")) {
- logger()->debug() << "Found Pebble:" << tmp;
+ qCDebug(l) << "Found Pebble:" << tmp;
pebbleProps = dict;
emit pebbleChanged();
return true;
diff --git a/daemon/dbusconnector.h b/daemon/dbusconnector.h
index 7ed3d56..6b48f99 100644
--- a/daemon/dbusconnector.h
+++ b/daemon/dbusconnector.h
@@ -4,14 +4,14 @@
#include <QObject>
#include <QStringList>
#include <QVariantMap>
-#include <Log4Qt/Logger>
+#include <QLoggingCategory>
// TODO Remove this.
class DBusConnector : public QObject
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
Q_PROPERTY(QVariantMap pebble READ pebble NOTIFY pebbleChanged)
QVariantMap pebbleProps;
diff --git a/daemon/jskitmanager.cpp b/daemon/jskitmanager.cpp
index 5c72acc..f6a3f24 100644
--- a/daemon/jskitmanager.cpp
+++ b/daemon/jskitmanager.cpp
@@ -5,7 +5,8 @@
#include "jskitobjects.h"
JSKitManager::JSKitManager(WatchConnector *watch, AppManager *apps, AppMsgManager *appmsg, Settings *settings, QObject *parent) :
- QObject(parent), _watch(watch), _apps(apps), _appmsg(appmsg), _settings(settings), _engine(0)
+ QObject(parent), l(metaObject()->className()),
+ _watch(watch), _apps(apps), _appmsg(appmsg), _settings(settings), _engine(0)
{
connect(_appmsg, &AppMsgManager::appStarted, this, &JSKitManager::handleAppStarted);
connect(_appmsg, &AppMsgManager::appStopped, this, &JSKitManager::handleAppStopped);
@@ -39,10 +40,10 @@ QString JSKitManager::describeError(QJSValue error)
void JSKitManager::showConfiguration()
{
if (_engine) {
- logger()->debug() << "requesting configuration";
+ qCDebug(l) << "requesting configuration";
_jspebble->invokeCallbacks("showConfiguration");
} else {
- logger()->warn() << "requested to show configuration, but JS engine is not running";
+ qCWarning(l) << "requested to show configuration, but JS engine is not running";
}
}
@@ -52,11 +53,11 @@ void JSKitManager::handleWebviewClosed(const QString &result)
QJSValue eventObj = _engine->newObject();
eventObj.setProperty("response", _engine->toScriptValue(result));
- logger()->debug() << "webview closed with the following result: " << result;
+ qCDebug(l) << "webview closed with the following result: " << result;
_jspebble->invokeCallbacks("webviewclosed", QJSValueList({eventObj}));
} else {
- logger()->warn() << "webview closed event, but JS engine is not running";
+ qCWarning(l) << "webview closed event, but JS engine is not running";
}
}
@@ -64,7 +65,7 @@ void JSKitManager::handleAppStarted(const QUuid &uuid)
{
AppInfo info = _apps->info(uuid);
if (!info.uuid().isNull() && info.isJSKit()) {
- logger()->debug() << "Preparing to start JSKit app" << info.uuid() << info.shortName();
+ qCDebug(l) << "Preparing to start JSKit app" << info.uuid() << info.shortName();
_curApp = info;
startJsApp();
}
@@ -74,7 +75,7 @@ void JSKitManager::handleAppStopped(const QUuid &uuid)
{
if (!_curApp.uuid().isNull()) {
if (_curApp.uuid() != uuid) {
- logger()->warn() << "Closed app with invalid UUID";
+ qCWarning(l) << "Closed app with invalid UUID";
}
stopJsApp();
@@ -85,10 +86,10 @@ void JSKitManager::handleAppStopped(const QUuid &uuid)
void JSKitManager::handleAppMessage(const QUuid &uuid, const QVariantMap &msg)
{
if (_curApp.uuid() == uuid) {
- logger()->debug() << "received a message for the current JSKit app";
+ qCDebug(l) << "received a message for the current JSKit app";
if (!_engine) {
- logger()->debug() << "but engine is stopped";
+ qCDebug(l) << "but engine is stopped";
return;
}
@@ -105,19 +106,19 @@ bool JSKitManager::loadJsFile(const QString &filename)
QFile file(filename);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- logger()->warn() << "Failed to load JS file:" << file.fileName();
+ qCWarning(l) << "Failed to load JS file:" << file.fileName();
return false;
}
- logger()->debug() << "now parsing" << file.fileName();
+ qCDebug(l) << "now parsing" << file.fileName();
QJSValue result = _engine->evaluate(QString::fromUtf8(file.readAll()), file.fileName());
if (result.isError()) {
- logger()->warn() << "error while evaluating JS script:" << describeError(result);
+ qCWarning(l) << "error while evaluating JS script:" << describeError(result);
return false;
}
- logger()->debug() << "JS script evaluated";
+ qCDebug(l) << "JS script evaluated";
return true;
}
@@ -126,7 +127,7 @@ void JSKitManager::startJsApp()
{
if (_engine) stopJsApp();
if (_curApp.uuid().isNull()) {
- logger()->warn() << "Attempting to start JS app with invalid UUID";
+ qCWarning(l) << "Attempting to start JS app with invalid UUID";
return;
}
@@ -136,7 +137,7 @@ void JSKitManager::startJsApp()
_jsstorage = new JSKitLocalStorage(_curApp.uuid(), this);
_jsgeo = new JSKitGeolocation(this);
- logger()->debug() << "starting JS app";
+ qCDebug(l) << "starting JS app";
QJSValue globalObj = _engine->globalObject();
@@ -185,7 +186,7 @@ void JSKitManager::stopJsApp()
{
if (!_engine) return; // Nothing to do!
- logger()->debug() << "stopping JS app";
+ qCDebug(l) << "stopping JS app";
if (!_curApp.uuid().isNull()) {
_appmsg->clearMessageHandler(_curApp.uuid());
diff --git a/daemon/jskitmanager.h b/daemon/jskitmanager.h
index 871ab8e..4482f34 100644
--- a/daemon/jskitmanager.h
+++ b/daemon/jskitmanager.h
@@ -14,7 +14,7 @@ class JSKitGeolocation;
class JSKitManager : public QObject
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
public:
explicit JSKitManager(WatchConnector *watch, AppManager *apps, AppMsgManager *appmsg, Settings *settings, QObject *parent = 0);
diff --git a/daemon/jskitobjects.cpp b/daemon/jskitobjects.cpp
index fe924e8..2aca027 100644
--- a/daemon/jskitobjects.cpp
+++ b/daemon/jskitobjects.cpp
@@ -11,7 +11,7 @@
static const char *token_salt = "0feeb7416d3c4546a19b04bccd8419b1";
JSKitPebble::JSKitPebble(const AppInfo &info, JSKitManager *mgr)
- : QObject(mgr), _appInfo(info), _mgr(mgr)
+ : QObject(mgr), l(metaObject()->className()), _appInfo(info), _mgr(mgr)
{
}
@@ -44,35 +44,35 @@ uint JSKitPebble::sendAppMessage(QJSValue message, QJSValue callbackForAck, QJSV
QPointer<JSKitPebble> pebbObj = this;
uint transactionId = _mgr->_appmsg->nextTransactionId();
- logger()->debug() << "sendAppMessage" << data;
+ qCDebug(l) << "sendAppMessage" << data;
_mgr->_appmsg->send(_appInfo.uuid(), data,
[pebbObj, transactionId, callbackForAck]() mutable {
if (pebbObj.isNull()) return;
if (callbackForAck.isCallable()) {
- pebbObj->logger()->debug() << "Invoking ack callback";
+ qCDebug(pebbObj->l) << "Invoking ack callback";
QJSValue event = pebbObj->buildAckEventObject(transactionId);
QJSValue result = callbackForAck.call(QJSValueList({event}));
if (result.isError()) {
- pebbObj->logger()->warn() << "error while invoking ACK callback" << callbackForAck.toString() << ":"
+ qCWarning(pebbObj->l) << "error while invoking ACK callback" << callbackForAck.toString() << ":"
<< JSKitManager::describeError(result);
}
} else {
- pebbObj->logger()->debug() << "Ack callback not callable";
+ qCDebug(pebbObj->l) << "Ack callback not callable";
}
},
[pebbObj, transactionId, callbackForNack]() mutable {
if (pebbObj.isNull()) return;
if (callbackForNack.isCallable()) {
- pebbObj->logger()->debug() << "Invoking nack callback";
+ qCDebug(pebbObj->l) << "Invoking nack callback";
QJSValue event = pebbObj->buildAckEventObject(transactionId, "NACK from watch");
QJSValue result = callbackForNack.call(QJSValueList({event}));
if (result.isError()) {
- pebbObj->logger()->warn() << "error while invoking NACK callback" << callbackForNack.toString() << ":"
+ qCWarning(pebbObj->l) << "error while invoking NACK callback" << callbackForNack.toString() << ":"
<< JSKitManager::describeError(result);
}
} else {
- pebbObj->logger()->debug() << "Nack callback not callable";
+ qCDebug(pebbObj->l) << "Nack callback not callable";
}
});
@@ -81,13 +81,13 @@ uint JSKitPebble::sendAppMessage(QJSValue message, QJSValue callbackForAck, QJSV
void JSKitPebble::showSimpleNotificationOnPebble(const QString &title, const QString &body)
{
- logger()->debug() << "showSimpleNotificationOnPebble" << title << body;
+ qCDebug(l) << "showSimpleNotificationOnPebble" << title << body;
emit _mgr->appNotification(_appInfo.uuid(), title, body);
}
void JSKitPebble::openURL(const QUrl &url)
{
- logger()->debug() << "opening url" << url.toString();
+ qCDebug(l) << "opening url" << url.toString();
emit _mgr->appOpenUrl(url);
}
@@ -102,13 +102,13 @@ QString JSKitPebble::getAccountToken() const
QString token = _mgr->_settings->property("accountToken").toString();
if (token.isEmpty()) {
token = QUuid::createUuid().toString();
- logger()->debug() << "created new account token" << token;
+ qCDebug(l) << "created new account token" << token;
_mgr->_settings->setProperty("accountToken", token);
}
hasher.addData(token.toLatin1());
QString hash = hasher.result().toHex();
- logger()->debug() << "returning account token" << hash;
+ qCDebug(l) << "returning account token" << hash;
return hash;
}
@@ -122,7 +122,7 @@ QString JSKitPebble::getWatchToken() const
hasher.addData(_mgr->_watch->serialNumber().toLatin1());
QString hash = hasher.result().toHex();
- logger()->debug() << "returning watch token" << hash;
+ qCDebug(l) << "returning watch token" << hash;
return hash;
}
@@ -158,23 +158,23 @@ void JSKitPebble::invokeCallbacks(const QString &type, const QJSValueList &args)
QList<QJSValue> &callbacks = _callbacks[type];
for (QList<QJSValue>::iterator it = callbacks.begin(); it != callbacks.end(); ++it) {
- logger()->debug() << "invoking callback" << type << it->toString();
+ qCDebug(l) << "invoking callback" << type << it->toString();
QJSValue result = it->call(args);
if (result.isError()) {
- logger()->warn() << "error while invoking callback" << type << it->toString() << ":"
+ qCWarning(l) << "error while invoking callback" << type << it->toString() << ":"
<< JSKitManager::describeError(result);
}
}
}
JSKitConsole::JSKitConsole(JSKitManager *mgr)
- : QObject(mgr)
+ : QObject(mgr), l(metaObject()->className())
{
}
void JSKitConsole::log(const QString &msg)
{
- logger()->info() << msg;
+ qCDebug(l) << msg;
}
JSKitLocalStorage::JSKitLocalStorage(const QUuid &uuid, JSKitManager *mgr)
@@ -237,17 +237,17 @@ QString JSKitLocalStorage::getStorageFileFor(const QUuid &uuid)
}
JSKitXMLHttpRequest::JSKitXMLHttpRequest(JSKitManager *mgr, QObject *parent)
- : QObject(parent), _mgr(mgr),
+ : QObject(parent), l(metaObject()->className()), _mgr(mgr),
_net(new QNetworkAccessManager(this)), _timeout(0), _reply(0)
{
- logger()->debug() << "constructed";
+ qCDebug(l) << "constructed";
connect(_net, &QNetworkAccessManager::authenticationRequired,
this, &JSKitXMLHttpRequest::handleAuthenticationRequired);
}
JSKitXMLHttpRequest::~JSKitXMLHttpRequest()
{
- logger()->debug() << "destructed";
+ qCDebug(l) << "destructed";
}
void JSKitXMLHttpRequest::open(const QString &method, const QString &url, bool async, const QString &username, const QString &password)
@@ -263,12 +263,12 @@ void JSKitXMLHttpRequest::open(const QString &method, const QString &url, bool a
_verb = method;
Q_UNUSED(async);
- logger()->debug() << "opened to URL" << _request.url().toString();
+ qCDebug(l) << "opened to URL" << _request.url().toString();
}
void JSKitXMLHttpRequest::setRequestHeader(const QString &header, const QString &value)
{
- logger()->debug() << "setRequestHeader" << header << value;
+ qCDebug(l) << "setRequestHeader" << header << value;
_request.setRawHeader(header.toLatin1(), value.toLatin1());
}
@@ -299,12 +299,12 @@ void JSKitXMLHttpRequest::send(const QJSValue &data)
byteData.append(array.property(i).toInt());
}
- logger()->debug() << "passed an ArrayBufferView of" << byteData.length() << "bytes";
+ qCDebug(l) << "passed an ArrayBufferView of" << byteData.length() << "bytes";
} else {
- logger()->warn() << "passed an unknown/invalid ArrayBuffer" << data.toString();
+ qCWarning(l) << "passed an unknown/invalid ArrayBuffer" << data.toString();
}
} else {
- logger()->warn() << "passed an unknown object" << data.toString();
+ qCWarning(l) << "passed an unknown object" << data.toString();
}
}
@@ -317,7 +317,7 @@ void JSKitXMLHttpRequest::send(const QJSValue &data)
buffer = 0;
}
- logger()->debug() << "sending" << _verb << "to" << _request.url() << "with" << QString::fromUtf8(byteData);
+ qCDebug(l) << "sending" << _verb << "to" << _request.url() << "with" << QString::fromUtf8(byteData);
_reply = _net->sendCustomRequest(_request, _verb.toLatin1(), buffer);
connect(_reply, &QNetworkReply::finished,
@@ -416,7 +416,7 @@ QString JSKitXMLHttpRequest::responseType() const
void JSKitXMLHttpRequest::setResponseType(const QString &type)
{
- logger()->debug() << "response type set to" << type;
+ qCDebug(l) << "response type set to" << type;
_responseType = type;
}
@@ -436,13 +436,13 @@ QJSValue JSKitXMLHttpRequest::response() const
array.setProperty(i, engine->toScriptValue<int>(_response[i]));
}
arrayBuf.setProperty("_bytes", array);
- logger()->debug() << "returning ArrayBuffer of" << _response.size() << "bytes";
+ qCDebug(l) << "returning ArrayBuffer of" << _response.size() << "bytes";
} else {
- logger()->warn() << "Cannot find proto of ArrayBuffer";
+ qCWarning(l) << "Cannot find proto of ArrayBuffer";
}
return arrayBuf;
} else {
- logger()->warn() << "unsupported responseType:" << _responseType;
+ qCWarning(l) << "unsupported responseType:" << _responseType;
return engine->toScriptValue<void*>(0);
}
}
@@ -455,12 +455,12 @@ QString JSKitXMLHttpRequest::responseText() const
void JSKitXMLHttpRequest::handleReplyFinished()
{
if (!_reply) {
- logger()->info() << "reply finished too late";
+ qCDebug(l) << "reply finished too late";
return;
}
_response = _reply->readAll();
- logger()->debug() << "reply finished, reply text:" << QString::fromUtf8(_response);
+ qCDebug(l) << "reply finished, reply text:" << QString::fromUtf8(_response);
emit readyStateChanged();
emit statusChanged();
@@ -469,34 +469,34 @@ void JSKitXMLHttpRequest::handleReplyFinished()
emit responseTextChanged();
if (_onload.isCallable()) {
- logger()->debug() << "going to call onload handler:" << _onload.toString();
+ qCDebug(l) << "going to call onload handler:" << _onload.toString();
QJSValue result = _onload.callWithInstance(_mgr->engine()->newQObject(this));
if (result.isError()) {
- logger()->warn() << "JS error on onload handler:" << JSKitManager::describeError(result);
+ qCWarning(l) << "JS error on onload handler:" << JSKitManager::describeError(result);
}
} else {
- logger()->debug() << "No onload set";
+ qCDebug(l) << "No onload set";
}
}
void JSKitXMLHttpRequest::handleReplyError(QNetworkReply::NetworkError code)
{
if (!_reply) {
- logger()->info() << "reply error too late";
+ qCDebug(l) << "reply error too late";
return;
}
- logger()->info() << "reply error" << code;
+ qCDebug(l) << "reply error" << code;
emit readyStateChanged();
emit statusChanged();
emit statusTextChanged();
if (_onerror.isCallable()) {
- logger()->debug() << "going to call onerror handler:" << _onload.toString();
+ qCDebug(l) << "going to call onerror handler:" << _onload.toString();
QJSValue result = _onerror.callWithInstance(_mgr->engine()->newQObject(this));
if (result.isError()) {
- logger()->warn() << "JS error on onerror handler:" << JSKitManager::describeError(result);
+ qCWarning(l) << "JS error on onerror handler:" << JSKitManager::describeError(result);
}
}
}
@@ -504,21 +504,22 @@ void JSKitXMLHttpRequest::handleReplyError(QNetworkReply::NetworkError code)
void JSKitXMLHttpRequest::handleAuthenticationRequired(QNetworkReply *reply, QAuthenticator *auth)
{
if (_reply == reply) {
- logger()->debug() << "authentication required";
+ qCDebug(l) << "authentication required";
if (!_username.isEmpty() || !_password.isEmpty()) {
- logger()->debug() << "using provided authorization:" << _username;
+ qCDebug(l) << "using provided authorization:" << _username;
auth->setUser(_username);
auth->setPassword(_password);
} else {
- logger()->debug() << "no username or password provided";
+ qCDebug(l) << "no username or password provided";
}
}
}
JSKitGeolocation::JSKitGeolocation(JSKitManager *mgr)
- : QObject(mgr), _mgr(mgr), _source(0), _lastWatchId(0)
+ : QObject(mgr), l(metaObject()->className()),
+ _mgr(mgr), _source(0), _lastWatchId(0)
{
}
@@ -539,16 +540,16 @@ void JSKitGeolocation::clearWatch(int watchId)
void JSKitGeolocation::handleError(QGeoPositionInfoSource::Error error)
{
- logger()->warn() << "positioning error: " << error;
+ qCWarning(l) << "positioning error: " << error;
// TODO
}
void JSKitGeolocation::handlePosition(const QGeoPositionInfo &pos)
{
- logger()->debug() << "got position at" << pos.timestamp() << "type" << pos.coordinate().type();
+ qCDebug(l) << "got position at" << pos.timestamp() << "type" << pos.coordinate().type();
if (_watches.empty()) {
- logger()->warn() << "got position update but no one is watching";
+ qCWarning(l) << "got position update but no one is watching";
_source->stopUpdates(); // Just in case.
return;
}
@@ -569,10 +570,10 @@ void JSKitGeolocation::handlePosition(const QGeoPositionInfo &pos)
void JSKitGeolocation::handleTimeout()
{
- logger()->info() << "positioning timeout";
+ qCDebug(l) << "positioning timeout";
if (_watches.empty()) {
- logger()->warn() << "got position timeout but no one is watching";
+ qCWarning(l) << "got position timeout but no one is watching";
_source->stopUpdates();
return;
}
@@ -581,7 +582,7 @@ void JSKitGeolocation::handleTimeout()
for (auto it = _watches.begin(); it != _watches.end(); /*no adv*/) {
if (it->timer.hasExpired(it->timeout)) {
- logger()->info() << "positioning timeout for watch" << it->watchId
+ qCDebug(l) << "positioning timeout for watch" << it->watchId
<< ", watch is" << it->timer.elapsed() << "ms old, timeout is" << it->timeout;
invokeCallback(it->errorCallback, obj);
@@ -603,11 +604,11 @@ void JSKitGeolocation::updateTimeouts()
{
int once_timeout = -1, updates_timeout = -1;
- logger()->debug() << Q_FUNC_INFO;
+ qCDebug(l) << Q_FUNC_INFO;
Q_FOREACH(const Watcher &watcher, _watches) {
qint64 rem_timeout = watcher.timeout - watcher.timer.elapsed();
- logger()->debug() << "watch" << watcher.watchId << "rem timeout" << rem_timeout;
+ qCDebug(l) << "watch" << watcher.watchId << "rem timeout" << rem_timeout;
if (rem_timeout >= 0) {
// In case it is too large...
rem_timeout = qMin<qint64>(rem_timeout, std::numeric_limits<int>::max());
@@ -620,16 +621,16 @@ void JSKitGeolocation::updateTimeouts()
}
if (updates_timeout >= 0) {
- logger()->debug() << "setting location update interval to" << updates_timeout;
+ qCDebug(l) << "setting location update interval to" << updates_timeout;
_source->setUpdateInterval(updates_timeout);
_source->startUpdates();
} else {
- logger()->debug() << "stopping updates";
+ qCDebug(l) << "stopping updates";
_source->stopUpdates();
}
if (once_timeout >= 0) {
- logger()->debug() << "requesting single location update with timeout" << once_timeout;
+ qCDebug(l) << "requesting single location update with timeout" << once_timeout;
_source->requestUpdate(once_timeout);
}
}
@@ -646,7 +647,7 @@ int JSKitGeolocation::setupWatcher(const QJSValue &successCallback, const QJSVal
qlonglong maximumAge = options.value("maximumAge", 0).toLongLong();
- logger()->debug() << "setting up watcher, gps=" << watcher.highAccuracy << "timeout=" << watcher.timeout << "maximumAge=" << maximumAge << "once=" << once;
+ qCDebug(l) << "setting up watcher, gps=" << watcher.highAccuracy << "timeout=" << watcher.timeout << "maximumAge=" << maximumAge << "once=" << once;
if (!_source) {
_source = QGeoPositionInfoSource::createDefaultSource(this);
@@ -661,7 +662,7 @@ int JSKitGeolocation::setupWatcher(const QJSValue &successCallback, const QJSVal
if (maximumAge > 0) {
QDateTime threshold = QDateTime::currentDateTime().addMSecs(-qint64(maximumAge));
QGeoPositionInfo pos = _source->lastKnownPosition(watcher.highAccuracy);
- logger()->debug() << "got pos timestamp" << pos.timestamp() << " but we want" << threshold;
+ qCDebug(l) << "got pos timestamp" << pos.timestamp() << " but we want" << threshold;
if (pos.isValid() && pos.timestamp() >= threshold) {
invokeCallback(watcher.successCallback, buildPositionObject(pos));
if (once) {
@@ -678,7 +679,7 @@ int JSKitGeolocation::setupWatcher(const QJSValue &successCallback, const QJSVal
watcher.timer.start();
_watches.append(watcher);
- logger()->debug() << "added new watch" << watcher.watchId;
+ qCDebug(l) << "added new watch" << watcher.watchId;
QMetaObject::invokeMethod(this, "updateTimeouts", Qt::QueuedConnection);
@@ -689,7 +690,7 @@ void JSKitGeolocation::removeWatcher(int watchId)
{
Watcher watcher;
- logger()->debug() << "removing watchId" << watcher.watchId;
+ qCDebug(l) << "removing watchId" << watcher.watchId;
for (int i = 0; i < _watches.size(); i++) {
if (_watches[i].watchId == watchId) {
@@ -699,7 +700,7 @@ void JSKitGeolocation::removeWatcher(int watchId)
}
if (watcher.watchId != watchId) {
- logger()->warn() << "watchId not found";
+ qCWarning(l) << "watchId not found";
return;
}
@@ -761,12 +762,12 @@ QJSValue JSKitGeolocation::buildPositionErrorObject(PositionError error, const Q
void JSKitGeolocation::invokeCallback(QJSValue callback, QJSValue event)
{
if (callback.isCallable()) {
- logger()->debug() << "invoking callback" << callback.toString();
+ qCDebug(l) << "invoking callback" << callback.toString();
QJSValue result = callback.call(QJSValueList({event}));
if (result.isError()) {
- logger()->warn() << "while invoking callback: " << JSKitManager::describeError(result);
+ qCWarning(l) << "while invoking callback: " << JSKitManager::describeError(result);
}
} else {
- logger()->warn() << "callback is not callable";
+ qCWarning(l) << "callback is not callable";
}
}
diff --git a/daemon/jskitobjects.h b/daemon/jskitobjects.h
index 532ce1b..1477fc6 100644
--- a/daemon/jskitobjects.h
+++ b/daemon/jskitobjects.h
@@ -11,7 +11,7 @@
class JSKitPebble : public QObject
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
public:
explicit JSKitPebble(const AppInfo &appInfo, JSKitManager *mgr);
@@ -44,7 +44,7 @@ private:
class JSKitConsole : public QObject
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
public:
explicit JSKitConsole(JSKitManager *mgr);
@@ -84,7 +84,7 @@ private:
class JSKitXMLHttpRequest : public QObject
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
Q_ENUMS(ReadyStates)
Q_PROPERTY(QJSValue onload READ onload WRITE setOnload)
@@ -168,7 +168,7 @@ class JSKitGeolocation : public QObject
{
Q_OBJECT
Q_ENUMS(PositionError)
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
struct Watcher;
diff --git a/daemon/manager.cpp b/daemon/manager.cpp
index 32b313f..6498c68 100644
--- a/daemon/manager.cpp
+++ b/daemon/manager.cpp
@@ -6,7 +6,7 @@
#include "watch_adaptor.h"
Manager::Manager(Settings *settings, QObject *parent) :
- QObject(parent), settings(settings),
+ QObject(parent), l(metaObject()->className()), settings(settings),
proxy(new PebbledProxy(this)),
watch(new WatchConnector(this)),
dbus(new DBusConnector(this)),
@@ -80,7 +80,7 @@ Manager::Manager(Settings *settings, QObject *parent) :
notification.setImage("icon-system-bluetooth-device");
if (btDevice.isValid()) {
- logger()->debug() << "BT local name:" << btDevice.name();
+ qCDebug(l) << "BT local name:" << btDevice.name();
connect(dbus, SIGNAL(pebbleChanged()), SLOT(onPebbleChanged()));
dbus->findPebble();
}
@@ -92,12 +92,12 @@ Manager::~Manager()
void Manager::onSettingChanged(const QString &key)
{
- logger()->debug() << __FUNCTION__ << key << ":" << settings->property(qPrintable(key));
+ qCDebug(l) << __FUNCTION__ << key << ":" << settings->property(qPrintable(key));
}
void Manager::onSettingsChanged()
{
- logger()->warn() << __FUNCTION__ << "Not implemented!";
+ qCWarning(l) << __FUNCTION__ << "Not implemented!";
}
void Manager::onPebbleChanged()
@@ -105,7 +105,7 @@ void Manager::onPebbleChanged()
const QVariantMap & pebble = dbus->pebble();
QString name = pebble["Name"].toString();
if (name.isEmpty()) {
- logger()->debug() << "Pebble gone";
+ qCDebug(l) << "Pebble gone";
} else {
watch->deviceConnect(name, pebble["Address"].toString());
}
@@ -116,23 +116,23 @@ void Manager::onConnectedChanged()
QString message = QString("%1 %2")
.arg(watch->name().isEmpty() ? "Pebble" : watch->name())
.arg(watch->isConnected() ? "connected" : "disconnected");
- logger()->debug() << message;
+ qCDebug(l) << message;
if (notification.isPublished()) notification.remove();
notification.setBody(message);
if (!notification.publish()) {
- logger()->debug() << "Failed publishing notification";
+ qCDebug(l) << "Failed publishing notification";
}
}
void Manager::onActiveVoiceCallChanged()
{
- logger()->debug() << "Manager::onActiveVoiceCallChanged()";
+ qCDebug(l) << "Manager::onActiveVoiceCallChanged()";
QVariant incomingCallNotification = settings->property("incomingCallNotification");
if (incomingCallNotification.isValid() && !incomingCallNotification.toBool()) {
- logger()->debug() << "Ignoring ActiveVoiceCallChanged because of setting!";
+ qCDebug(l) << "Ignoring ActiveVoiceCallChanged because of setting!";
return;
}
@@ -148,12 +148,12 @@ void Manager::onActiveVoiceCallStatusChanged()
{
VoiceCallHandler* handler = voice->activeVoiceCall();
if (!handler) {
- logger()->debug() << "ActiveVoiceCall destroyed";
+ qCDebug(l) << "ActiveVoiceCall destroyed";
watch->endPhoneCall();
return;
}
- logger()->debug() << "handlerId:" << handler->handlerId()
+ qCDebug(l) << "handlerId:" << handler->handlerId()
<< "providerId:" << handler->providerId()
<< "status:" << handler->status()
<< "statusText:" << handler->statusText()
@@ -161,28 +161,28 @@ void Manager::onActiveVoiceCallStatusChanged()
<< "incoming:" << handler->isIncoming();
if (!watch->isConnected()) {
- logger()->debug() << "Watch is not connected";
+ qCDebug(l) << "Watch is not connected";
return;
}
switch ((VoiceCallHandler::VoiceCallStatus)handler->status()) {
case VoiceCallHandler::STATUS_ALERTING:
case VoiceCallHandler::STATUS_DIALING:
- logger()->debug() << "Tell outgoing:" << handler->lineId();
+ qCDebug(l) << "Tell outgoing:" << handler->lineId();
watch->ring(handler->lineId(), findPersonByNumber(handler->lineId()), false);
break;
case VoiceCallHandler::STATUS_INCOMING:
case VoiceCallHandler::STATUS_WAITING:
- logger()->debug() << "Tell incoming:" << handler->lineId();
+ qCDebug(l) << "Tell incoming:" << handler->lineId();
watch->ring(handler->lineId(), findPersonByNumber(handler->lineId()));
break;
case VoiceCallHandler::STATUS_NULL:
case VoiceCallHandler::STATUS_DISCONNECTED:
- logger()->debug() << "Endphone";
+ qCDebug(l) << "Endphone";
watch->endPhoneCall();
break;
case VoiceCallHandler::STATUS_ACTIVE:
- logger()->debug() << "Startphone";
+ qCDebug(l) << "Startphone";
watch->startPhoneCall();
break;
case VoiceCallHandler::STATUS_HELD:
@@ -208,7 +208,7 @@ QString Manager::findPersonByNumber(QString number)
void Manager::onVoiceError(const QString &message)
{
- logger()->error() << "Error:" << message;
+ qCCritical(l) << "Error:" << message;
}
@@ -262,11 +262,11 @@ QString Manager::getCurrentProfile() const
QDBusMessage::createMethodCall("com.nokia.profiled", "/com/nokia/profiled", "com.nokia.profiled", "get_profile"));
if (profile.isValid()) {
QString currentProfile = profile.value();
- logger()->debug() << "Got profile" << currentProfile;
+ qCDebug(l) << "Got profile" << currentProfile;
return currentProfile;
}
- logger()->error() << profile.error().message();
+ qCCritical(l) << profile.error().message();
return QString();
}
@@ -294,11 +294,11 @@ void Manager::applyProfile()
<< newProfile);
if (res.isValid()) {
if (!res.value()) {
- logger()->error() << "Unable to set profile" << newProfile;
+ qCCritical(l) << "Unable to set profile" << newProfile;
}
}
else {
- logger()->error() << res.error().message();
+ qCCritical(l) << res.error().message();
}
}
}
@@ -309,11 +309,11 @@ void Manager::transliterateMessage(const QString &text)
UErrorCode status = U_ZERO_ERROR;
transliterator.reset(icu::Transliterator::createInstance(icu::UnicodeString::fromUTF8("Any-Latin; Latin-ASCII"),UTRANS_FORWARD, status));
if (U_FAILURE(status)) {
- logger()->warn() << "Error creaing ICU Transliterator \"Any-Latin; Latin-ASCII\":" << u_errorName(status);
+ qCWarning(l) << "Error creaing ICU Transliterator \"Any-Latin; Latin-ASCII\":" << u_errorName(status);
}
}
if (!transliterator.isNull()) {
- logger()->debug() << "String before transliteration:" << text;
+ qCDebug(l) << "String before transliteration:" << text;
icu::UnicodeString uword = icu::UnicodeString::fromUTF8(text.toStdString());
transliterator->transliterate(uword);
@@ -322,7 +322,7 @@ void Manager::transliterateMessage(const QString &text)
uword.toUTF8String(translited);
const_cast<QString&>(text) = QString::fromStdString(translited);
- logger()->debug() << "String after transliteration:" << text;
+ qCDebug(l) << "String after transliteration:" << text;
}
}
@@ -413,14 +413,14 @@ QString PebbledProxy::StartAppConfiguration(const QString &uuid)
QDBusConnection conn = connection();
if (manager()->currentAppUuid != uuid) {
- logger()->warn() << "Called StartAppConfiguration but the uuid" << uuid << "is not running";
+ qCWarning(l) << "Called StartAppConfiguration but the uuid" << uuid << "is not running";
sendErrorReply(msg.interface() + ".Error.AppNotRunning",
"The requested app is not currently opened in the watch");
return QString();
}
if (!manager()->js->isJSKitAppRunning()) {
- logger()->warn() << "Called StartAppConfiguration but the uuid" << uuid << "is not a JS app";
+ qCWarning(l) << "Called StartAppConfiguration but the uuid" << uuid << "is not a JS app";
sendErrorReply(msg.interface() + ".Error.JSNotActive",
"The requested app is not a PebbleKit JS application");
return QString();
diff --git a/daemon/manager.h b/daemon/manager.h
index efe9b82..9a4ed0f 100644
--- a/daemon/manager.h
+++ b/daemon/manager.h
@@ -20,7 +20,7 @@
#include <QtContacts/QContactManager>
#include <QtContacts/QContactDetailFilter>
#include <MNotification>
-#include <Log4Qt/Logger>
+#include <QLoggingCategory>
#include <unicode/translit.h>
@@ -31,7 +31,7 @@ class PebbledProxy;
class Manager : public QObject, protected QDBusContext
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
friend class PebbledProxy;
@@ -103,7 +103,7 @@ private slots:
class PebbledProxy : public QObject, protected QDBusContext
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
Q_PROPERTY(QString Name READ Name NOTIFY NameChanged)
Q_PROPERTY(QString Address READ Address NOTIFY AddressChanged)
@@ -116,7 +116,8 @@ class PebbledProxy : public QObject, protected QDBusContext
inline QVariantMap pebble() const { return manager()->dbus->pebble(); }
public:
- inline explicit PebbledProxy(QObject *parent) : QObject(parent) {}
+ inline explicit PebbledProxy(QObject *parent)
+ : QObject(parent), l(metaObject()->className()) {}
inline QString Name() const { return pebble()["Name"].toString(); }
inline QString Address() const { return pebble()["Address"].toString(); }
diff --git a/daemon/musicmanager.cpp b/daemon/musicmanager.cpp
index d34ae5c..385abbf 100644
--- a/daemon/musicmanager.cpp
+++ b/daemon/musicmanager.cpp
@@ -3,7 +3,8 @@
#include "musicmanager.h"
MusicManager::MusicManager(WatchConnector *watch, QObject *parent)
- : QObject(parent), watch(watch), _watcher(new QDBusServiceWatcher(this))
+ : QObject(parent), l(metaObject()->className()),
+ watch(watch), _watcher(new QDBusServiceWatcher(this))
{
QDBusConnection bus = QDBusConnection::sessionBus();
QDBusConnectionInterface *bus_iface = bus.interface();
@@ -46,7 +47,7 @@ MusicManager::MusicManager(WatchConnector *watch, QObject *parent)
void MusicManager::switchToService(const QString &service)
{
if (_curService != service) {
- logger()->debug() << "switching to mpris service" << service;
+ qCDebug(l) << "switching to mpris service" << service;
_curService = service;
if (_curService.isEmpty()) {
@@ -66,10 +67,10 @@ void MusicManager::fetchMetadataFromService()
call << "org.mpris.MediaPlayer2.Player" << "Metadata";
QDBusReply<QDBusVariant> reply = QDBusConnection::sessionBus().call(call);
if (reply.isValid()) {
- logger()->debug() << "got mpris metadata from service" << _curService;
+ qCDebug(l) << "got mpris metadata from service" << _curService;
_curMetadata = qdbus_cast<QVariantMap>(reply.value().variant().value<QDBusArgument>());
} else {
- logger()->error() << reply.error().message();
+ qCWarning(l) << reply.error().message();
}
}
}
@@ -82,7 +83,7 @@ void MusicManager::sendCurrentMprisMetadata()
QString album = _curMetadata.value("xesam:album").toString().left(30);
QString artist = _curMetadata.value("xesam:artist").toString().left(30);
- logger()->debug() << "sending mpris metadata:" << track << album << artist;
+ qCDebug(l) << "sending mpris metadata:" << track << album << artist;
watch->sendMusicNowPlaying(track, album, artist);
}
@@ -92,7 +93,7 @@ void MusicManager::callMprisMethod(const QString &method)
Q_ASSERT(!method.isEmpty());
Q_ASSERT(!_curService.isEmpty());
- logger()->debug() << _curService << "->" << method;
+ qCDebug(l) << _curService << "->" << method;
QDBusConnection bus = QDBusConnection::sessionBus();
QDBusMessage call = QDBusMessage::createMethodCall(_curService,
@@ -103,16 +104,16 @@ void MusicManager::callMprisMethod(const QString &method)
QDBusError err = bus.call(call);
if (err.isValid()) {
- logger()->error() << "while calling mpris method on" << _curService << ":" << err.message();
+ qCWarning(l) << "while calling mpris method on" << _curService << ":" << err.message();
}
}
void MusicManager::handleMusicControl(WatchConnector::MusicControl operation)
{
- logger()->debug() << "operation from watch:" << operation;
+ qCDebug(l) << "operation from watch:" << operation;
if (_curService.isEmpty()) {
- logger()->info() << "can't do any music operation, no mpris interface active";
+ qCDebug(l) << "can't do any music operation, no mpris interface active";
return;
}
@@ -148,17 +149,17 @@ void MusicManager::handleMusicControl(WatchConnector::MusicControl operation)
else {
volume -= 0.1;
}
- logger()->debug() << "Setting volume" << volume;
+ qCDebug(l) << "Setting volume" << volume;
call = QDBusMessage::createMethodCall(_curService, "/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", "Set");
call << "org.mpris.MediaPlayer2.Player" << "Volume" << QVariant::fromValue(QDBusVariant(volume));
QDBusError err = QDBusConnection::sessionBus().call(call);
if (err.isValid()) {
- logger()->error() << err.message();
+ qCWarning(l) << err.message();
}
} else {
- logger()->error() << volumeReply.error().message();
+ qCWarning(l) << volumeReply.error().message();
}
}
break;
@@ -168,7 +169,7 @@ void MusicManager::handleMusicControl(WatchConnector::MusicControl operation)
break;
default:
- logger()->warn() << "Operation" << operation << "not supported";
+ qCWarning(l) << "Operation" << operation << "not supported";
break;
}
}
@@ -194,7 +195,7 @@ void MusicManager::handleMprisPropertiesChanged(const QString &interface, const
if (changed.contains("Metadata")) {
QVariantMap metadata = qdbus_cast<QVariantMap>(changed.value("Metadata").value<QDBusArgument>());
- logger()->debug() << "received new metadata" << metadata;
+ qCDebug(l) << "received new metadata" << metadata;
_curMetadata = metadata;
}
diff --git a/daemon/musicmanager.h b/daemon/musicmanager.h
index 89e5fd7..14aa6fb 100644
--- a/daemon/musicmanager.h
+++ b/daemon/musicmanager.h
@@ -9,7 +9,7 @@
class MusicManager : public QObject, protected QDBusContext
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
public:
explicit MusicManager(WatchConnector *watch, QObject *parent = 0);
diff --git a/daemon/notificationmanager.cpp b/daemon/notificationmanager.cpp
index 079bdb0..d983539 100644
--- a/daemon/notificationmanager.cpp
+++ b/daemon/notificationmanager.cpp
@@ -26,7 +26,7 @@ public:
};
NotificationManager::NotificationManager(Settings *settings, QObject *parent)
- : QObject(parent), d_ptr(new NotificationManagerPrivate(this)), settings(settings)
+ : QObject(parent), l(metaObject()->className()), d_ptr(new NotificationManagerPrivate(this)), settings(settings)
{
Q_D(NotificationManager);
QDBusConnection::sessionBus().registerObject("/org/freedesktop/Notifications", this, QDBusConnection::ExportAllSlots);
@@ -117,8 +117,8 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons
return 0;
}
- logger()->debug() << Q_FUNC_INFO << "Got notification via dbus from" << this->getCleanAppName(app_name);
- logger()->debug() << hints;
+ qCDebug(l) << Q_FUNC_INFO << "Got notification via dbus from" << this->getCleanAppName(app_name);
+ qCDebug(l) << hints;
// Avoid sending a reply for this method call, since we've received it because we're eavesdropping.
// The actual target of the method call will send the proper reply.
@@ -128,7 +128,7 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons
if (app_name == "messageserver5") {
QVariant notificationsEmails = settings->property("notificationsEmails");
if (!notificationsEmails.isValid() || !notificationsEmails.toBool()) {
- logger()->debug() << "Ignoring email notification because of setting!";
+ qCDebug(l) << "Ignoring email notification because of setting!";
return 0;
}
@@ -151,13 +151,13 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons
if (category == "x-nemo.call.missed") {
QVariant notificationsMissedCall = settings->property("notificationsMissedCall");
if (notificationsMissedCall.isValid() && !notificationsMissedCall.toBool()) {
- logger()->debug() << "Ignoring MissedCall notification because of setting!";
+ qCDebug(l) << "Ignoring MissedCall notification because of setting!";
return 0;
}
} else {
QVariant notificationsCommhistoryd = settings->property("notificationsCommhistoryd");
if (notificationsCommhistoryd.isValid() && !notificationsCommhistoryd.toBool()) {
- logger()->debug() << "Ignoring commhistoryd notification because of setting!";
+ qCDebug(l) << "Ignoring commhistoryd notification because of setting!";
return 0;
}
}
@@ -168,7 +168,7 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons
} else if (app_name == "harbour-mitakuuluu2-server") {
QVariant notificationsMitakuuluu = settings->property("notificationsMitakuuluu");
if (notificationsMitakuuluu.isValid() && !notificationsMitakuuluu.toBool()) {
- logger()->debug() << "Ignoring mitakuuluu notification because of setting!";
+ qCDebug(l) << "Ignoring mitakuuluu notification because of setting!";
return 0;
}
@@ -178,7 +178,7 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons
} else if (app_name == "twitter-notifications-client") {
QVariant notificationsTwitter = settings->property("notificationsTwitter");
if (notificationsTwitter.isValid() && !notificationsTwitter.toBool()) {
- logger()->debug() << "Ignoring twitter notification because of setting!";
+ qCDebug(l) << "Ignoring twitter notification because of setting!";
return 0;
}
@@ -193,17 +193,17 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons
QStringHash categoryParams = this->getCategoryParams(category);
int prio = categoryParams.value("x-nemo-priority", "0").toInt();
- logger()->debug() << "MSG Prio:" << prio;
+ qCDebug(l) << "MSG Prio:" << prio;
QVariant notificationsAll = settings->property("notificationsAll");
if ((!notificationsAll.isValid() || !notificationsAll.toBool()) && prio <= 10) {
- logger()->debug() << "Ignoring notification because of setting! (all)";
+ qCDebug(l) << "Ignoring notification because of setting! (all)";
return 0;
}
QVariant notificationsOther = settings->property("notificationsOther");
if (notificationsOther.isValid() && !notificationsOther.toBool() && prio < 90) {
- logger()->debug() << "Ignoring notification because of setting! (other)";
+ qCDebug(l) << "Ignoring notification because of setting! (other)";
return 0;
}
@@ -222,7 +222,7 @@ uint NotificationManager::Notify(const QString &app_name, uint replaces_id, cons
//Never send empty data and subject
if (data.isEmpty() && subject.isEmpty()) {
- logger()->warn() << Q_FUNC_INFO << "Empty subject and data in dbus app:" << app_name;
+ qCWarning(l) << Q_FUNC_INFO << "Empty subject and data in dbus app:" << app_name;
return 0;
}
diff --git a/daemon/notificationmanager.h b/daemon/notificationmanager.h
index 0432f00..037ff07 100644
--- a/daemon/notificationmanager.h
+++ b/daemon/notificationmanager.h
@@ -3,7 +3,7 @@
#include <QObject>
#include <QtDBus/QDBusContext>
-#include <Log4Qt/Logger>
+#include <QLoggingCategory>
#include "settings.h"
#include <QDBusInterface>
@@ -14,7 +14,7 @@ typedef QHash<QString, QString> QStringHash;
class NotificationManager : public QObject, protected QDBusContext
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Notifications")
Q_PROPERTY(QDBusInterface* interface READ interface)
diff --git a/daemon/packer.cpp b/daemon/packer.cpp
index df32a4a..abbb873 100644
--- a/daemon/packer.cpp
+++ b/daemon/packer.cpp
@@ -1,6 +1,8 @@
#include "packer.h"
#include "watchconnector.h"
+QLoggingCategory Packer::l("Packer");
+
void Packer::writeBytes(int n, const QByteArray &b)
{
if (b.size() > n) {
@@ -29,7 +31,7 @@ void Packer::writeDict(const QMap<int, QVariant> &d)
{
int size = d.size();
if (size > 0xFF) {
- logger()->warn() << "Dictionary is too large to encode";
+ qCWarning(l) << "Dictionary is too large to encode";
writeLE<quint8>(0);
return;
}
@@ -110,7 +112,7 @@ void Packer::writeDict(const QMap<int, QVariant> &d)
}
default:
- logger()->warn() << "Unknown dict item type:" << it.value().typeName();
+ qCWarning(l) << "Unknown dict item type:" << it.value().typeName();
/* Fallthrough */
case QMetaType::QString:
case QMetaType::QUrl:
diff --git a/daemon/packer.h b/daemon/packer.h
index ceb6593..fbf5f4b 100644
--- a/daemon/packer.h
+++ b/daemon/packer.h
@@ -6,11 +6,11 @@
#include <QString>
#include <QUuid>
#include <QVariantMap>
-#include <Log4Qt/Logger>
+#include <QLoggingCategory>
class Packer
{
- LOG4QT_DECLARE_STATIC_LOGGER(logger, Packer)
+ static QLoggingCategory l;
public:
Packer(QByteArray *buf);
diff --git a/daemon/unpacker.cpp b/daemon/unpacker.cpp
index e904db8..1f1d564 100644
--- a/daemon/unpacker.cpp
+++ b/daemon/unpacker.cpp
@@ -1,6 +1,8 @@
#include "unpacker.h"
#include "watchconnector.h"
+QLoggingCategory Unpacker::l("Unpacker");
+
QByteArray Unpacker::readBytes(int n)
{
if (checkBad(n)) return QByteArray();
diff --git a/daemon/unpacker.h b/daemon/unpacker.h
index 000c3e8..46e6d57 100644
--- a/daemon/unpacker.h
+++ b/daemon/unpacker.h
@@ -6,11 +6,11 @@
#include <QString>
#include <QUuid>
#include <QVariantMap>
-#include <Log4Qt/Logger>
+#include <QLoggingCategory>
class Unpacker
{
- LOG4QT_DECLARE_STATIC_LOGGER(logger, Unpacker)
+ static QLoggingCategory l;
public:
Unpacker(const QByteArray &data);
diff --git a/daemon/uploadmanager.cpp b/daemon/uploadmanager.cpp
index 5976fe6..b379880 100644
--- a/daemon/uploadmanager.cpp
+++ b/daemon/uploadmanager.cpp
@@ -7,12 +7,13 @@ static const int CHUNK_SIZE = 2000;
using std::function;
UploadManager::UploadManager(WatchConnector *watch, QObject *parent) :
- QObject(parent), watch(watch), _lastUploadId(0), _state(StateNotStarted)
+ QObject(parent), l(metaObject()->className()), watch(watch),
+ _lastUploadId(0), _state(StateNotStarted)
{
watch->setEndpointHandler(WatchConnector::watchPUTBYTES,
[this](const QByteArray &msg) {
if (_pending.empty()) {
- logger()->warn() << "putbytes message, but queue is empty!";
+ qCWarning(l) << "putbytes message, but queue is empty!";
return false;
}
handleMessage(msg);
@@ -40,7 +41,7 @@ uint UploadManager::upload(WatchConnector::UploadType type, int index, const QSt
upload.progressCallback = progressCallback;
if (upload.remaining <= 0) {
- logger()->warn() << "upload is empty";
+ qCWarning(l) << "upload is empty";
if (errorCallback) {
errorCallback(-1);
return -1;
@@ -75,13 +76,13 @@ uint UploadManager::uploadFile(const QString &filename, QIODevice *device, Succe
void UploadManager::cancel(uint id, int code)
{
if (_pending.empty()) {
- logger()->warn() << "cannot cancel, empty queue";
+ qCWarning(l) << "cannot cancel, empty queue";
return;
}
if (id == _pending.head().id) {
PendingUpload upload = _pending.dequeue();
- logger()->debug() << "aborting current upload" << id << "(code:" << code << ")";
+ qCDebug(l) << "aborting current upload" << id << "(code:" << code << ")";
if (_state != StateNotStarted && _state != StateWaitForToken && _state != StateComplete) {
QByteArray msg;
@@ -89,7 +90,7 @@ void UploadManager::cancel(uint id, int code)
p.write<quint8>(WatchConnector::putbytesABORT);
p.write<quint32>(_token);
- logger()->debug() << "sending abort for upload" << id;
+ qCDebug(l) << "sending abort for upload" << id;
watch->sendMessage(WatchConnector::watchPUTBYTES, msg);
}
@@ -107,7 +108,7 @@ void UploadManager::cancel(uint id, int code)
} else {
for (int i = 1; i < _pending.size(); ++i) {
if (_pending[i].id == id) {
- logger()->debug() << "cancelling upload" << id << "(code:" << code << ")";
+ qCDebug(l) << "cancelling upload" << id << "(code:" << code << ")";
if (_pending[i].errorCallback) {
_pending[i].errorCallback(code);
}
@@ -115,7 +116,7 @@ void UploadManager::cancel(uint id, int code)
return;
}
}
- logger()->warn() << "cannot cancel, id" << id << "not found";
+ qCWarning(l) << "cannot cancel, id" << id << "not found";
}
}
@@ -135,7 +136,7 @@ void UploadManager::startNextUpload()
p.writeCString(upload.filename);
}
- logger()->debug() << "starting new upload, size:" << upload.remaining << ", type:" << upload.type << ", slot:" << upload.index;
+ qCDebug(l) << "starting new upload, size:" << upload.remaining << ", type:" << upload.type << ", slot:" << upload.index;
_state = StateWaitForToken;
watch->sendMessage(WatchConnector::watchPUTBYTES, msg);
@@ -150,7 +151,7 @@ void UploadManager::handleMessage(const QByteArray &msg)
int status = u.read<quint8>();
if (u.bad() || status != 1) {
- logger()->warn() << "upload" << upload.id << "got error code=" << status;
+ qCWarning(l) << "upload" << upload.id << "got error code=" << status;
cancel(upload.id, status);
return;
}
@@ -158,14 +159,14 @@ void UploadManager::handleMessage(const QByteArray &msg)
quint32 recv_token = u.read<quint32>();
if (u.bad()) {
- logger()->warn() << "upload" << upload.id << ": could not read the token";
+ qCWarning(l) << "upload" << upload.id << ": could not read the token";
cancel(upload.id, -1);
return;
}
if (_state != StateNotStarted && _state != StateWaitForToken && _state != StateComplete) {
if (recv_token != _token) {
- logger()->warn() << "upload" << upload.id << ": invalid token";
+ qCWarning(l) << "upload" << upload.id << ": invalid token";
cancel(upload.id, -1);
return;
}
@@ -173,16 +174,16 @@ void UploadManager::handleMessage(const QByteArray &msg)
switch (_state) {
case StateNotStarted:
- logger()->warn() << "got packet when upload is not started";
+ qCWarning(l) << "got packet when upload is not started";
break;
case StateWaitForToken:
- logger()->debug() << "token received";
+ qCDebug(l) << "token received";
_token = recv_token;
_state = StateInProgress;
/* fallthrough */
case StateInProgress:
- logger()->debug() << "moving to the next chunk";
+ qCDebug(l) << "moving to the next chunk";
if (upload.progressCallback) {
// Report that the previous chunk has been succesfully uploaded
upload.progressCallback(1.0 - (qreal(upload.remaining) / upload.size));
@@ -193,7 +194,7 @@ void UploadManager::handleMessage(const QByteArray &msg)
return;
}
} else {
- logger()->debug() << "no additional chunks, commit";
+ qCDebug(l) << "no additional chunks, commit";
_state = StateCommit;
if (!commit(upload)) {
cancel(upload.id, -1);
@@ -202,7 +203,7 @@ void UploadManager::handleMessage(const QByteArray &msg)
}
break;
case StateCommit:
- logger()->debug() << "commited succesfully";
+ qCDebug(l) << "commited succesfully";
if (upload.progressCallback) {
// Report that all chunks have been succesfully uploaded
upload.progressCallback(1.0);
@@ -214,7 +215,7 @@ void UploadManager::handleMessage(const QByteArray &msg)
}
break;
case StateComplete:
- logger()->debug() << "upload" << upload.id << "succesful, invoking callback";
+ qCDebug(l) << "upload" << upload.id << "succesful, invoking callback";
if (upload.successCallback) {
upload.successCallback();
}
@@ -226,7 +227,7 @@ void UploadManager::handleMessage(const QByteArray &msg)
}
break;
default:
- logger()->warn() << "received message in wrong state";
+ qCWarning(l) << "received message in wrong state";
break;
}
}
@@ -237,7 +238,7 @@ bool UploadManager::uploadNextChunk(PendingUpload &upload)
if (upload.remaining < CHUNK_SIZE && chunk.size() < upload.remaining) {
// Short read!
- logger()->warn() << "short read during upload" << upload.id;
+ qCWarning(l) << "short read during upload" << upload.id;
return false;
}
@@ -251,14 +252,14 @@ bool UploadManager::uploadNextChunk(PendingUpload &upload)
p.write<quint32>(chunk.size());
msg.append(chunk);
- logger()->debug() << "sending a chunk of" << chunk.size() << "bytes";
+ qCDebug(l) << "sending a chunk of" << chunk.size() << "bytes";
watch->sendMessage(WatchConnector::watchPUTBYTES, msg);
upload.remaining -= chunk.size();
upload.crc.addData(chunk);
- logger()->debug() << "remaining" << upload.remaining << "/" << upload.size << "bytes";
+ qCDebug(l) << "remaining" << upload.remaining << "/" << upload.size << "bytes";
return true;
}
@@ -274,7 +275,7 @@ bool UploadManager::commit(PendingUpload &upload)
p.write<quint32>(_token);
p.write<quint32>(upload.crc.result());
- logger()->debug() << "commiting upload" << upload.id
+ qCDebug(l) << "commiting upload" << upload.id
<< "with crc" << qPrintable(QString("0x%1").arg(upload.crc.result(), 0, 16));
watch->sendMessage(WatchConnector::watchPUTBYTES, msg);
@@ -291,7 +292,7 @@ bool UploadManager::complete(PendingUpload &upload)
p.write<quint8>(WatchConnector::putbytesCOMPLETE);
p.write<quint32>(_token);
- logger()->debug() << "completing upload" << upload.id;
+ qCDebug(l) << "completing upload" << upload.id;
watch->sendMessage(WatchConnector::watchPUTBYTES, msg);
diff --git a/daemon/uploadmanager.h b/daemon/uploadmanager.h
index 45453b6..1980f96 100644
--- a/daemon/uploadmanager.h
+++ b/daemon/uploadmanager.h
@@ -9,7 +9,7 @@
class UploadManager : public QObject
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
public:
explicit UploadManager(WatchConnector *watch, QObject *parent = 0);
diff --git a/daemon/voicecallhandler.cpp b/daemon/voicecallhandler.cpp
index 8b638b8..cce1792 100644
--- a/daemon/voicecallhandler.cpp
+++ b/daemon/voicecallhandler.cpp
@@ -43,10 +43,10 @@ public:
Constructs a new proxy interface for the provided voice call handlerId.
*/
VoiceCallHandler::VoiceCallHandler(const QString &handlerId, QObject *parent)
- : QObject(parent), d_ptr(new VoiceCallHandlerPrivate(this, handlerId))
+ : QObject(parent), l(metaObject()->className()), d_ptr(new VoiceCallHandlerPrivate(this, handlerId))
{
Q_D(VoiceCallHandler);
- logger()->debug() << QString("Creating D-Bus interface to: ") + handlerId;
+ qCDebug(l) << QString("Creating D-Bus interface to: ") + handlerId;
d->interface = new QDBusInterface("org.nemomobile.voicecall",
"/calls/" + handlerId,
"org.nemomobile.voicecall.VoiceCall",
@@ -89,7 +89,7 @@ void VoiceCallHandler::initialize(bool notifyError)
}
}
else {
- logger()->error() << d->interface->lastError().name() << d->interface->lastError().message();
+ qCCritical(l) << d->interface->lastError().name() << d->interface->lastError().message();
}
}
@@ -103,7 +103,7 @@ bool VoiceCallHandler::getProperties()
QDBusReply<QVariantMap> reply = props.call("GetAll", d->interface->interface());
if (reply.isValid()) {
QVariantMap props = reply.value();
- logger()->debug() << props;
+ qCDebug(l) << props;
d->providerId = props["providerId"].toString();
d->duration = props["duration"].toInt();
d->status = props["status"].toInt();
@@ -116,7 +116,7 @@ bool VoiceCallHandler::getProperties()
return true;
}
else {
- logger()->error() << "Failed to get VoiceCall properties from VCM D-Bus service.";
+ qCCritical(l) << "Failed to get VoiceCall properties from VCM D-Bus service.";
return false;
}
}
@@ -124,7 +124,7 @@ bool VoiceCallHandler::getProperties()
void VoiceCallHandler::onDurationChanged(int duration)
{
Q_D(VoiceCallHandler);
- //logger()->debug() <<"onDurationChanged"<<duration;
+ //qCDebug(l) <<"onDurationChanged"<<duration;
d->duration = duration;
emit durationChanged();
}
@@ -132,7 +132,7 @@ void VoiceCallHandler::onDurationChanged(int duration)
void VoiceCallHandler::onStatusChanged(int status, QString statusText)
{
Q_D(VoiceCallHandler);
- logger()->debug() <<"onStatusChanged" << status << statusText;
+ qCDebug(l) <<"onStatusChanged" << status << statusText;
d->status = status;
d->statusText = statusText;
// we still fetch all properties to be sure all properties are present.
@@ -143,7 +143,7 @@ void VoiceCallHandler::onStatusChanged(int status, QString statusText)
void VoiceCallHandler::onLineIdChanged(QString lineId)
{
Q_D(VoiceCallHandler);
- logger()->debug() << "onLineIdChanged" << lineId;
+ qCDebug(l) << "onLineIdChanged" << lineId;
d->lineId = lineId;
emit lineIdChanged();
}
@@ -151,7 +151,7 @@ void VoiceCallHandler::onLineIdChanged(QString lineId)
void VoiceCallHandler::onStartedAtChanged(const QDateTime &startedAt)
{
Q_D(VoiceCallHandler);
- logger()->debug() << "onStartedAtChanged" << startedAt;
+ qCDebug(l) << "onStartedAtChanged" << startedAt;
d->startedAt = d->interface->property("startedAt").toDateTime();
emit startedAtChanged();
}
@@ -159,7 +159,7 @@ void VoiceCallHandler::onStartedAtChanged(const QDateTime &startedAt)
void VoiceCallHandler::onEmergencyChanged(bool isEmergency)
{
Q_D(VoiceCallHandler);
- logger()->debug() << "onEmergencyChanged" << isEmergency;
+ qCDebug(l) << "onEmergencyChanged" << isEmergency;
d->emergency = isEmergency;
emit emergencyChanged();
}
@@ -167,7 +167,7 @@ void VoiceCallHandler::onEmergencyChanged(bool isEmergency)
void VoiceCallHandler::onMultipartyChanged(bool isMultiparty)
{
Q_D(VoiceCallHandler);
- logger()->debug() << "onMultipartyChanged" << isMultiparty;
+ qCDebug(l) << "onMultipartyChanged" << isMultiparty;
d->multiparty = isMultiparty;
emit multipartyChanged();
}
@@ -175,7 +175,7 @@ void VoiceCallHandler::onMultipartyChanged(bool isMultiparty)
void VoiceCallHandler::onForwardedChanged(bool isForwarded)
{
Q_D(VoiceCallHandler);
- logger()->debug() << "onForwardedChanged" << isForwarded;
+ qCDebug(l) << "onForwardedChanged" << isForwarded;
d->forwarded = isForwarded;
emit forwardedChanged();
}
@@ -341,10 +341,10 @@ void VoiceCallHandler::onPendingCallFinished(QDBusPendingCallWatcher *watcher)
QDBusPendingReply<bool> reply = *watcher;
if (reply.isError()) {
- logger()->error() << QString::fromLatin1("Received error reply for member: %1 (%2)").arg(reply.reply().member()).arg(reply.error().message());
+ qCCritical(l) << QString::fromLatin1("Received error reply for member: %1 (%2)").arg(reply.reply().member()).arg(reply.error().message());
emit this->error(reply.error().message());
watcher->deleteLater();
} else {
- logger()->debug() << QString::fromLatin1("Received successful reply for member: %1").arg(reply.reply().member());
+ qCDebug(l) << QString::fromLatin1("Received successful reply for member: %1").arg(reply.reply().member());
}
}
diff --git a/daemon/voicecallhandler.h b/daemon/voicecallhandler.h
index f7fbb8b..fb20ac7 100644
--- a/daemon/voicecallhandler.h
+++ b/daemon/voicecallhandler.h
@@ -4,12 +4,12 @@
#include <QObject>
#include <QDateTime>
#include <QDBusPendingCallWatcher>
-#include <Log4Qt/Logger>
+#include <QLoggingCategory>
class VoiceCallHandler : public QObject
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
Q_ENUMS(VoiceCallStatus)
diff --git a/daemon/voicecallmanager.cpp b/daemon/voicecallmanager.cpp
index 9fd4339..afb3629 100644
--- a/daemon/voicecallmanager.cpp
+++ b/daemon/voicecallmanager.cpp
@@ -30,7 +30,7 @@ public:
};
VoiceCallManager::VoiceCallManager(Settings *settings, QObject *parent)
- : QObject(parent), d_ptr(new VoiceCallManagerPrivate(this)), settings(settings)
+ : QObject(parent), l(metaObject()->className()), d_ptr(new VoiceCallManagerPrivate(this)), settings(settings)
{
this->initialize();
}
@@ -98,7 +98,7 @@ QString VoiceCallManager::defaultProviderId() const
{
Q_D(const VoiceCallManager);
if(d->providers.count() == 0) {
- logger()->debug() << Q_FUNC_INFO << "No provider added";
+ qCDebug(l) << Q_FUNC_INFO << "No provider added";
return QString::null;
}
@@ -295,7 +295,7 @@ void VoiceCallManager::onPendingCallFinished(QDBusPendingCallWatcher *watcher)
if (reply.isError()) {
emit this->error(reply.error().message());
} else {
- logger()->debug() << QString("Received successful reply for member: ") + reply.reply().member();
+ qCDebug(l) << QString("Received successful reply for member: ") + reply.reply().member();
}
watcher->deleteLater();
@@ -308,7 +308,7 @@ void VoiceCallManager::onPendingSilenceFinished(QDBusPendingCallWatcher *watcher
if (reply.isError()) {
emit this->error(reply.error().message());
} else {
- logger()->debug() << QString("Received successful reply for member: ") + reply.reply().member();
+ qCDebug(l) << QString("Received successful reply for member: ") + reply.reply().member();
}
watcher->deleteLater();
diff --git a/daemon/voicecallmanager.h b/daemon/voicecallmanager.h
index 5c21269..ec51230 100644
--- a/daemon/voicecallmanager.h
+++ b/daemon/voicecallmanager.h
@@ -7,7 +7,7 @@
#include <QObject>
#include <QDBusInterface>
#include <QDBusPendingCallWatcher>
-#include <Log4Qt/Logger>
+#include <QLoggingCategory>
class VoiceCallProviderData
{
@@ -28,7 +28,7 @@ typedef QList<VoiceCallHandler*> VoiceCallHandlerList;
class VoiceCallManager : public QObject
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
Q_PROPERTY(QDBusInterface* interface READ interface)
diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp
index 27a5511..ef032f7 100644
--- a/daemon/watchconnector.cpp
+++ b/daemon/watchconnector.cpp
@@ -8,7 +8,7 @@ static const int RECONNECT_TIMEOUT = 500; //ms
static const bool PROTOCOL_DEBUG = false;
WatchConnector::WatchConnector(QObject *parent) :
- QObject(parent), socket(nullptr), is_connected(false)
+ QObject(parent), l(metaObject()->className()), socket(nullptr), is_connected(false)
{
reconnectTimer.setSingleShot(true);
connect(&reconnectTimer, SIGNAL(timeout()), SLOT(reconnect()));
@@ -38,18 +38,18 @@ WatchConnector::WatchConnector(QObject *parent) :
QByteArray address = u.readBytes(6);
if (u.bad()) {
- logger()->warn() << "short read while reading firmware version";
+ qCWarning(l) << "short read while reading firmware version";
}
- logger()->debug() << "got version information"
- << version << version_string << commit
- << is_recovery << hw_platform << metadata_version;
- logger()->debug() << "recovery version information"
- << safe_version << safe_version_string << safe_commit
- << safe_is_recovery << safe_hw_platform << safe_metadata_version;
- logger()->debug() << "hardware information" << bootLoaderTimestamp << hardwareRevision;
- logger()->debug() << "serial number" << serialNumber.left(3) << "...";
- logger()->debug() << "bt address" << address.toHex();
+ qCDebug(l) << "got version information"
+ << version << version_string << commit
+ << is_recovery << hw_platform << metadata_version;
+ qCDebug(l) << "recovery version information"
+ << safe_version << safe_version_string << safe_commit
+ << safe_is_recovery << safe_hw_platform << safe_metadata_version;
+ qCDebug(l) << "hardware information" << bootLoaderTimestamp << hardwareRevision;
+ qCDebug(l) << "serial number" << serialNumber.left(3) << "...";
+ qCDebug(l) << "bt address" << address.toHex();
this->_serialNumber = serialNumber;
@@ -65,10 +65,10 @@ void WatchConnector::deviceDiscovered(const QBluetoothDeviceInfo &device)
{
//FIXME TODO: Configurable
if (device.name().startsWith("Pebble")) {
- logger()->debug() << "Found Pebble:" << device.name() << '(' << device.address().toString() << ')';
+ qCDebug(l) << "Found Pebble:" << device.name() << '(' << device.address().toString() << ')';
handleWatch(device.name(), device.address().toString());
} else {
- logger()->debug() << "Found other device:" << device.name() << '(' << device.address().toString() << ')';
+ qCDebug(l) << "Found other device:" << device.name() << '(' << device.address().toString() << ')';
}
}
@@ -79,7 +79,7 @@ void WatchConnector::deviceConnect(const QString &name, const QString &address)
void WatchConnector::reconnect()
{
- logger()->debug() << "reconnect" << _last_name;
+ qCDebug(l) << "reconnect" << _last_name;
if (!_last_name.isEmpty() && !_last_address.isEmpty()) {
deviceConnect(_last_name, _last_address);
}
@@ -87,16 +87,16 @@ void WatchConnector::reconnect()
void WatchConnector::disconnect()
{
- logger()->debug() << "disconnecting";
+ qCDebug(l) << "disconnecting";
socket->close();
socket->deleteLater();
reconnectTimer.stop();
- logger()->debug() << "stopped reconnect timer";
+ qCDebug(l) << "stopped reconnect timer";
}
void WatchConnector::handleWatch(const QString &name, const QString &address)
{
- logger()->debug() << "handleWatch" << name << address;
+ qCDebug(l) << "handleWatch" << name << address;
reconnectTimer.stop();
if (socket != nullptr && socket->isOpen()) {
socket->close();
@@ -113,12 +113,8 @@ void WatchConnector::handleWatch(const QString &name, const QString &address)
_serialNumber.clear();
}
- logger()->debug() << "Creating socket";
-#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
- socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket);
-#else
+ qCDebug(l) << "Creating socket";
socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
-#endif
connect(socket, SIGNAL(readyRead()), SLOT(onReadSocket()));
connect(socket, SIGNAL(bytesWritten(qint64)), SLOT(onBytesWritten(qint64)));
connect(socket, SIGNAL(connected()), SLOT(onConnected()));
@@ -181,8 +177,8 @@ bool WatchConnector::dispatchMessage(uint endpoint, const QByteArray &data)
}
}
- logger()->info() << "message to endpoint" << decodeEndpoint(endpoint) << "was not dispatched";
- logger()->debug() << data.toHex();
+ qCDebug(l) << "message to endpoint" << decodeEndpoint(endpoint) << "was not dispatched";
+ qCDebug(l) << data.toHex();
return false;
}
@@ -190,7 +186,7 @@ void WatchConnector::onReadSocket()
{
static const int header_length = 4;
- logger()->debug() << "readyRead bytesAvailable =" << socket->bytesAvailable();
+ qCDebug(l) << "readyRead bytesAvailable =" << socket->bytesAvailable();
QBluetoothSocket *socket = qobject_cast<QBluetoothSocket *>(sender());
Q_ASSERT(socket && socket == this->socket);
@@ -207,19 +203,19 @@ void WatchConnector::onReadSocket()
// Sanity checks on the message_length
if (message_length == 0) {
- logger()->warn() << "received empty message";
+ qCWarning(l) << "received empty message";
socket->read(header_length); // skip this header
continue; // check if there are additional headers.
} else if (message_length > 8 * 1024) {
// Protocol does not allow messages more than 8K long, seemingly.
- logger()->warn() << "received message size too long: " << message_length;
+ qCWarning(l) << "received message size too long: " << message_length;
socket->readAll(); // drop entire input buffer
return;
}
// Now wait for the entire message
if (socket->bytesAvailable() < header_length + message_length) {
- logger()->debug() << "incomplete msg body in read buffer";
+ qCDebug(l) << "incomplete msg body in read buffer";
return; // try again once more data comes in
}
@@ -230,8 +226,8 @@ void WatchConnector::onReadSocket()
// Now read the rest of the message
QByteArray data = socket->read(message_length);
- logger()->debug() << "received message of length" << message_length << "to endpoint" << decodeEndpoint(endpoint);
- if (PROTOCOL_DEBUG) logger()->trace() << data.toHex();
+ qCDebug(l) << "received message of length" << message_length << "to endpoint" << decodeEndpoint(endpoint);
+ if (PROTOCOL_DEBUG) qCDebug(l) << data.toHex();
dispatchMessage(endpoint, data);
}
@@ -239,14 +235,14 @@ void WatchConnector::onReadSocket()
void WatchConnector::onConnected()
{
- logger()->debug() << "Connected!";
+ qCDebug(l) << "Connected!";
bool was_connected = is_connected;
is_connected = true;
reconnectTimer.stop();
reconnectTimer.setInterval(0);
if (!was_connected) {
if (!writeData.isEmpty()) {
- logger()->info() << "Found" << writeData.length() << "bytes in write buffer - resending";
+ qCDebug(l) << "Found" << writeData.length() << "bytes in write buffer - resending";
sendData(writeData);
}
if (_serialNumber.isEmpty()) {
@@ -259,7 +255,7 @@ void WatchConnector::onConnected()
void WatchConnector::onDisconnected()
{
- logger()->debug() << "Disconnected!";
+ qCDebug(l) << "Disconnected!";
bool was_connected = is_connected;
is_connected = false;
@@ -279,15 +275,15 @@ void WatchConnector::onDisconnected()
reconnectTimer.setInterval(reconnectTimer.interval() + RECONNECT_TIMEOUT);
}
reconnectTimer.start();
- logger()->debug() << "will reconnect in" << reconnectTimer.interval() << "ms";
+ qCDebug(l) << "will reconnect in" << reconnectTimer.interval() << "ms";
}
void WatchConnector::onError(QBluetoothSocket::SocketError error)
{
if (error == QBluetoothSocket::UnknownSocketError) {
- logger()->info() << error << socket->errorString();
+ qCDebug(l) << error << socket->errorString();
} else {
- logger()->error() << "error connecting Pebble:" << error << socket->errorString();
+ qCCritical(l) << "error connecting Pebble:" << error << socket->errorString();
}
}
@@ -295,11 +291,11 @@ void WatchConnector::sendData(const QByteArray &data)
{
writeData.append(data);
if (socket == nullptr) {
- logger()->debug() << "no socket - reconnecting";
+ qCDebug(l) << "no socket - reconnecting";
reconnect();
} else if (is_connected) {
- logger()->debug() << "writing" << data.length() << "bytes to socket";
- if (PROTOCOL_DEBUG) logger()->trace() << data.toHex();
+ qCDebug(l) << "writing" << data.length() << "bytes to socket";
+ if (PROTOCOL_DEBUG) qCDebug(l) << data.toHex();
socket->write(data);
}
}
@@ -307,12 +303,12 @@ void WatchConnector::sendData(const QByteArray &data)
void WatchConnector::onBytesWritten(qint64 bytes)
{
writeData.remove(0, bytes);
- logger()->debug() << "socket written" << bytes << "bytes," << writeData.length() << "left";
+ qCDebug(l) << "socket written" << bytes << "bytes," << writeData.length() << "left";
}
void WatchConnector::sendMessage(uint endpoint, const QByteArray &data, const EndpointHandlerFunc &callback)
{
- logger()->debug() << "sending message to endpoint" << decodeEndpoint(endpoint);
+ qCDebug(l) << "sending message to endpoint" << decodeEndpoint(endpoint);
QByteArray msg;
// First send the length
diff --git a/daemon/watchconnector.h b/daemon/watchconnector.h
index 45fd3c7..6c28e88 100644
--- a/daemon/watchconnector.h
+++ b/daemon/watchconnector.h
@@ -38,12 +38,12 @@
#include <QBluetoothDeviceInfo>
#include <QBluetoothSocket>
#include <QBluetoothServiceInfo>
-#include <Log4Qt/Logger>
+#include <QLoggingCategory>
class WatchConnector : public QObject
{
Q_OBJECT
- LOG4QT_DECLARE_QCLASS_LOGGER
+ QLoggingCategory l;
Q_ENUMS(Endpoint)