diff options
| author | Tomasz Sterna <tomek@xiaoka.com> | 2014-12-12 20:57:07 +0100 |
|---|---|---|
| committer | Tomasz Sterna <tomek@xiaoka.com> | 2014-12-12 20:57:07 +0100 |
| commit | 80cf5c3c0b779c869e61dca0da9eec18b962c8ce (patch) | |
| tree | afaccaf434d4bab5d4941103ec3dce662292010b /daemon | |
| parent | 8e8c5da2d50ce71bd795803154636e0b6d30912b (diff) | |
Replaced Log4Qt with Qt 5.2+ QLoggingCategory
Diffstat (limited to 'daemon')
| -rw-r--r-- | daemon/daemon.cpp | 30 | ||||
| -rw-r--r-- | daemon/daemon.pro | 21 | ||||
| -rw-r--r-- | daemon/dbusconnector.cpp | 20 | ||||
| -rw-r--r-- | daemon/dbusconnector.h | 4 | ||||
| -rw-r--r-- | daemon/manager.cpp | 54 | ||||
| -rw-r--r-- | daemon/manager.h | 4 | ||||
| -rw-r--r-- | daemon/notificationmanager.cpp | 24 | ||||
| -rw-r--r-- | daemon/notificationmanager.h | 4 | ||||
| -rw-r--r-- | daemon/voicecallhandler.cpp | 28 | ||||
| -rw-r--r-- | daemon/voicecallhandler.h | 4 | ||||
| -rw-r--r-- | daemon/voicecallmanager.cpp | 8 | ||||
| -rw-r--r-- | daemon/voicecallmanager.h | 4 | ||||
| -rw-r--r-- | daemon/watchcommands.cpp | 28 | ||||
| -rw-r--r-- | daemon/watchcommands.h | 4 | ||||
| -rw-r--r-- | daemon/watchconnector.cpp | 48 | ||||
| -rw-r--r-- | daemon/watchconnector.h | 8 |
16 files changed, 126 insertions, 167 deletions
diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp index 9d89980..69bcbe6 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,33 +48,16 @@ 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); - // Init logging should be called after app object creation as initLogging() will examine - // QCoreApplication for determining the .conf files locations - initLogging(); + // Init logging should be called after app object creation + QLoggingCategory::setFilterRules("*.debug=false\n" + "fc.io.debug=true"); - Log4Qt::Logger::logger(QLatin1String("Main Logger"))->info() << argv[0] << APP_VERSION; + QLoggingCategory l("main"); + qCDebug(l) << argv[0] << APP_VERSION; Settings settings; watch::WatchConnector watch; diff --git a/daemon/daemon.pro b/daemon/daemon.pro index 0528ec9..85705aa 100644 --- a/daemon/daemon.pro +++ b/daemon/daemon.pro @@ -4,11 +4,10 @@ CONFIG += console CONFIG += link_pkgconfig QT -= gui -QT += bluetooth dbus contacts +QT += core bluetooth dbus contacts PKGCONFIG += mlite5 QMAKE_CXXFLAGS += -std=c++0x -LIBS += -llog4qt LIBS += -licuuc -licui18n DEFINES += APP_VERSION=\\\"$$VERSION\\\" @@ -36,28 +35,14 @@ HEADERS += \ settings.h OTHER_FILES += \ - org.pebbled.xml \ - ../log4qt-debug.conf \ - ../log4qt-release.conf + org.pebbled.xml -INSTALLS += target pebbled confile +INSTALLS += target pebbled target.path = /usr/bin pebbled.files = $${TARGET}.service pebbled.path = /usr/lib/systemd/user -CONFIG(debug, debug|release) { - message(Debug build) - confile.extra = cp $$PWD/../log4qt-debug.conf $$OUT_PWD/../log4qt.conf -} -else { - message(Release build) - 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/dbusconnector.cpp b/daemon/dbusconnector.cpp index 8bde322..4827b1f 100644 --- a/daemon/dbusconnector.cpp +++ b/daemon/dbusconnector.cpp @@ -14,7 +14,7 @@ //dbus-send --system --dest=org.bluez --print-reply $devpath org.bluez.Input.Connect DBusConnector::DBusConnector(QObject *parent) : - QObject(parent) + QObject(parent), l(metaObject()->className()) { QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface(); @@ -23,7 +23,7 @@ DBusConnector::DBusConnector(QObject *parent) : dbusServices = serviceNames.value(); } else { - logger()->error() << serviceNames.error().message(); + qCCritical(l) << serviceNames.error().message(); } connect(interface, SIGNAL(serviceRegistered(const QString &)), SLOT(onServiceRegistered(const QString &))); connect(interface, SIGNAL(serviceUnregistered(const QString &)), SLOT(onServiceUnregistered(const QString &))); @@ -37,14 +37,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; } @@ -52,7 +52,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; } @@ -64,16 +64,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; @@ -85,12 +85,12 @@ bool DBusConnector::findPebble() void DBusConnector::onServiceRegistered(const QString &name) { - logger()->debug() << "DBus service online:" << name; + qCDebug(l) << "DBus service online:" << name; if (!dbusServices.contains(name)) dbusServices.append(name); } void DBusConnector::onServiceUnregistered(const QString &name) { - logger()->debug() << "DBus service offline:" << name; + qCDebug(l) << "DBus service offline:" << name; if (dbusServices.contains(name)) dbusServices.removeAll(name); } diff --git a/daemon/dbusconnector.h b/daemon/dbusconnector.h index e6dd793..e44ff3f 100644 --- a/daemon/dbusconnector.h +++ b/daemon/dbusconnector.h @@ -4,12 +4,12 @@ #include <QObject> #include <QStringList> #include <QVariantMap> -#include <Log4Qt/Logger> +#include <QLoggingCategory> class DBusConnector : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; Q_PROPERTY(QVariantMap pebble READ pebble NOTIFY pebbleChanged) Q_PROPERTY(QStringList services READ services NOTIFY servicesChanged) diff --git a/daemon/manager.cpp b/daemon/manager.cpp index b01006c..fc64b63 100644 --- a/daemon/manager.cpp +++ b/daemon/manager.cpp @@ -6,7 +6,7 @@ #include <QtContacts/QContactPhoneNumber> Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice, NotificationManager *notifications, Settings *settings) : - QObject(0), watch(watch), dbus(dbus), voice(voice), notifications(notifications), commands(new WatchCommands(watch, this)), + QObject(0), l(metaObject()->className()), watch(watch), dbus(dbus), voice(voice), notifications(notifications), commands(new WatchCommands(watch, this)), settings(settings), notification(MNotification::DeviceEvent) { connect(settings, SIGNAL(valueChanged(QString)), SLOT(onSettingChanged(const QString&))); @@ -58,7 +58,7 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan 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(); } @@ -67,12 +67,12 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan 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() @@ -80,7 +80,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()); } @@ -91,13 +91,13 @@ 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"; } if (watch->isConnected()) { @@ -110,7 +110,7 @@ void Manager::onConnectedChanged() setMprisMetadata(Metadata.value().variant().value<QDBusArgument>()); } else { - logger()->error() << Metadata.error().message(); + qCCritical(l) << Metadata.error().message(); setMprisMetadata(QVariantMap()); } } @@ -119,11 +119,11 @@ void Manager::onConnectedChanged() 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; } @@ -139,12 +139,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() @@ -152,28 +152,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: @@ -199,7 +199,7 @@ QString Manager::findPersonByNumber(QString number) void Manager::onVoiceError(const QString &message) { - logger()->error() << "Error:" << message; + qCCritical(l) << "Error:" << message; } @@ -256,7 +256,7 @@ void Manager::hangupAll() void Manager::onMprisPropertiesChanged(QString interface, QMap<QString,QVariant> changed, QStringList invalidated) { - logger()->debug() << interface << changed << invalidated; + qCDebug(l) << interface << changed << invalidated; if (changed.contains("Metadata")) { setMprisMetadata(changed.value("Metadata").value<QDBusArgument>()); @@ -270,7 +270,7 @@ void Manager::onMprisPropertiesChanged(QString interface, QMap<QString,QVariant> } lastSeenMpris = message().service(); - logger()->debug() << "lastSeenMpris:" << lastSeenMpris; + qCDebug(l) << "lastSeenMpris:" << lastSeenMpris; } QString Manager::mpris() @@ -306,11 +306,11 @@ QString Manager::getCurrentProfile() 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(); } @@ -338,11 +338,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(); } } } @@ -353,11 +353,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); @@ -366,6 +366,6 @@ 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; } } diff --git a/daemon/manager.h b/daemon/manager.h index 9de5667..4a3e760 100644 --- a/daemon/manager.h +++ b/daemon/manager.h @@ -14,7 +14,7 @@ #include <QtContacts/QContactManager> #include <QtContacts/QContactDetailFilter> #include <MNotification> -#include <Log4Qt/Logger> +#include <QLoggingCategory> #include <unicode/translit.h> @@ -25,7 +25,7 @@ class Manager : protected QDBusContext { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; friend class PebbledProxy; 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/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 ac03b51..68f36e0 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; } @@ -288,7 +288,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(); @@ -301,7 +301,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 b7241ef..e0b610a 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/watchcommands.cpp b/daemon/watchcommands.cpp index b16efb5..9845849 100644 --- a/daemon/watchcommands.cpp +++ b/daemon/watchcommands.cpp @@ -7,12 +7,12 @@ using namespace watch; WatchCommands::WatchCommands(WatchConnector *watch, QObject *parent) : - QObject(parent), watch(watch) + QObject(parent), l(metaObject()->className()), watch(watch) {} void WatchCommands::processMessage(uint endpoint, QByteArray data) { - logger()->debug() << __FUNCTION__ << endpoint << "/" << data.toHex() << data.length(); + qCDebug(l) << __FUNCTION__ << endpoint << "/" << data.toHex() << data.length(); switch (endpoint) { case WatchConnector::watchPHONE_VERSION: watch->sendPhoneVersion(); @@ -26,12 +26,12 @@ void WatchCommands::processMessage(uint endpoint, QByteArray data) musicControl(WatchConnector::MusicControl(data.at(0))); break; case WatchConnector::watchSYSTEM_MESSAGE: - logger()->info() << "Got SYSTEM_MESSAGE" << WatchConnector::SystemMessage(data.at(0)); + qCDebug(l) << "Got SYSTEM_MESSAGE" << WatchConnector::SystemMessage(data.at(0)); // TODO: handle systemBLUETOOTH_START_DISCOVERABLE/systemBLUETOOTH_END_DISCOVERABLE break; default: - logger()->info() << __FUNCTION__ << "endpoint" << endpoint << "not supported yet"; + qCDebug(l) << __FUNCTION__ << "endpoint" << endpoint << "not supported yet"; } } @@ -40,17 +40,17 @@ void WatchCommands::onMprisMetadataChanged(QVariantMap metadata) QString track = metadata.value("xesam:title").toString(); QString album = metadata.value("xesam:album").toString(); QString artist = metadata.value("xesam:artist").toString(); - logger()->debug() << __FUNCTION__ << track << album << artist; + qCDebug(l) << __FUNCTION__ << track << album << artist; watch->sendMusicNowPlaying(track, album, artist); } void WatchCommands::musicControl(WatchConnector::MusicControl operation) { - logger()->debug() << "Operation:" << operation; + qCDebug(l) << "Operation:" << operation; QString mpris = parent()->property("mpris").toString(); if (mpris.isEmpty()) { - logger()->debug() << "No mpris interface active"; + qCDebug(l) << "No mpris interface active"; return; } @@ -85,16 +85,16 @@ void WatchCommands::musicControl(WatchConnector::MusicControl operation) else { volume -= 0.1; } - logger()->debug() << "Setting volume" << volume; + qCDebug(l) << "Setting volume" << volume; QDBusError err = QDBusConnection::sessionBus().call( QDBusMessage::createMethodCall(mpris, "/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", "Set") << "org.mpris.MediaPlayer2.Player" << "Volume" << QVariant::fromValue(QDBusVariant(volume))); if (err.isValid()) { - logger()->error() << err.message(); + qCCritical(l) << err.message(); } } else { - logger()->error() << VolumeReply.error().message(); + qCCritical(l) << VolumeReply.error().message(); } } return; @@ -103,20 +103,20 @@ void WatchCommands::musicControl(WatchConnector::MusicControl operation) return; case WatchConnector::musicSEND_NOW_PLAYING: - logger()->warn() << "Operation" << operation << "not supported"; + qCWarning(l) << "Operation" << operation << "not supported"; return; } if (method.isEmpty()) { - logger()->error() << "Requested unsupported operation" << operation; + qCCritical(l) << "Requested unsupported operation" << operation; return; } - logger()->debug() << operation << "->" << method; + qCDebug(l) << operation << "->" << method; QDBusError err = QDBusConnection::sessionBus().call( QDBusMessage::createMethodCall(mpris, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player", method)); if (err.isValid()) { - logger()->error() << err.message(); + qCCritical(l) << err.message(); } } diff --git a/daemon/watchcommands.h b/daemon/watchcommands.h index 8626b7c..1fa4859 100644 --- a/daemon/watchcommands.h +++ b/daemon/watchcommands.h @@ -2,14 +2,14 @@ #define WATCHCOMMANDS_H #include "watchconnector.h" -#include <Log4Qt/Logger> +#include <QLoggingCategory> #include <QObject> class WatchCommands : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; watch::WatchConnector *watch; diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp index a240b04..7c2b272 100644 --- a/daemon/watchconnector.cpp +++ b/daemon/watchconnector.cpp @@ -8,7 +8,7 @@ using namespace watch; static int RECONNECT_TIMEOUT = 500; //ms 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())); @@ -22,10 +22,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() << ')'; } } @@ -36,7 +36,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); } @@ -44,16 +44,16 @@ void WatchConnector::reconnect() void WatchConnector::disconnect() { - logger()->debug() << __FUNCTION__; + qCDebug(l) << __FUNCTION__; 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(); @@ -65,12 +65,8 @@ void WatchConnector::handleWatch(const QString &name, const QString &address) _last_address = address; if (emit_name) emit nameChanged(); - 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())); @@ -96,7 +92,7 @@ void WatchConnector::decodeMsg(QByteArray data) } if (data.length() < 4) { - logger()->error() << "Can not decode message data length invalid: " << data.toHex(); + qCCritical(l) << "Can not decode message data length invalid: " << data.toHex(); return; } @@ -109,15 +105,15 @@ void WatchConnector::decodeMsg(QByteArray data) endpoint = (data.at(index) << 8) + data.at(index+1); index += 2; - logger()->debug() << "Length:" << datalen << "Endpoint:" << decodeEndpoint(endpoint); - logger()->debug() << "Data:" << data.mid(index).toHex(); + qCDebug(l) << "Length:" << datalen << "Endpoint:" << decodeEndpoint(endpoint); + qCDebug(l) << "Data:" << data.mid(index).toHex(); emit messageDecoded(endpoint, data.mid(index, datalen)); } void WatchConnector::onReadSocket() { - logger()->debug() << "read"; + qCDebug(l) << "read"; QBluetoothSocket *socket = qobject_cast<QBluetoothSocket *>(sender()); if (!socket) return; @@ -131,14 +127,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 (not was_connected) { if (not writeData.isEmpty()) { - logger()->info() << "Found" << writeData.length() << "bytes in write buffer - resending"; + qCDebug(l) << "Found" << writeData.length() << "bytes in write buffer - resending"; sendData(writeData); } emit connectedChanged(); @@ -147,7 +143,7 @@ void WatchConnector::onConnected() void WatchConnector::onDisconnected() { - logger()->debug() << "Disconnected!"; + qCDebug(l) << "Disconnected!"; bool was_connected = is_connected; is_connected = false; @@ -167,15 +163,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(); } } @@ -183,12 +179,12 @@ void WatchConnector::sendData(const QByteArray &data) { writeData = data; if (socket == nullptr) { - logger()->debug() << "No socket - reconnecting"; + qCDebug(l) << "No socket - reconnecting"; reconnect(); return; } if (is_connected) { - logger()->debug() << "Writing" << data.length() << "bytes to socket"; + qCDebug(l) << "Writing" << data.length() << "bytes to socket"; socket->write(data); } } @@ -196,12 +192,12 @@ void WatchConnector::sendData(const QByteArray &data) void WatchConnector::onBytesWritten(qint64 bytes) { writeData = writeData.mid(bytes); - logger()->debug() << "Socket written" << bytes << "bytes," << writeData.length() << "left"; + qCDebug(l) << "Socket written" << bytes << "bytes," << writeData.length() << "left"; } void WatchConnector::sendMessage(uint endpoint, QByteArray data) { - logger()->debug() << "Sending message"; + qCDebug(l) << "Sending message"; QByteArray msg; // First send the length diff --git a/daemon/watchconnector.h b/daemon/watchconnector.h index b64e31b..fa8d18b 100644 --- a/daemon/watchconnector.h +++ b/daemon/watchconnector.h @@ -37,11 +37,7 @@ #include <QBluetoothDeviceInfo> #include <QBluetoothSocket> #include <QBluetoothServiceInfo> -#include <Log4Qt/Logger> - -#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) -using namespace QtBluetooth; -#endif +#include <QLoggingCategory> namespace watch { @@ -49,7 +45,7 @@ namespace watch class WatchConnector : public QObject { Q_OBJECT - LOG4QT_DECLARE_QCLASS_LOGGER + QLoggingCategory l; Q_ENUMS(Endpoints) |
