Port from own logger to QLoggingCategory

This commit is contained in:
Hannah von Reth 2015-11-27 18:48:34 +01:00
parent 9a8752ad09
commit b5fcc90724
45 changed files with 231 additions and 430 deletions

View File

@ -15,7 +15,6 @@ public:
DisplayTest(): DisplayTest():
app(QStringLiteral("Test"), Icon::defaultIcon()) app(QStringLiteral("Test"), Icon::defaultIcon())
{ {
SnoreLog::setDebugLvl(3);
SnoreCore &instance = SnoreCore::instance(); SnoreCore &instance = SnoreCore::instance();
instance.loadPlugins(SnorePlugin::BACKEND); instance.loadPlugins(SnorePlugin::BACKEND);
instance.setSettingsValue(QStringLiteral("Timeout"), 5, LOCAL_SETTING); instance.setSettingsValue(QStringLiteral("Timeout"), 5, LOCAL_SETTING);

View File

@ -14,7 +14,6 @@ class SnoreBenchmark : public QObject
public: public:
SnoreBenchmark() SnoreBenchmark()
{ {
SnoreLog::setDebugLvl(3);
SnoreCore &instance = SnoreCore::instance(); SnoreCore &instance = SnoreCore::instance();
instance.loadPlugins(SnorePlugin::BACKEND); instance.loadPlugins(SnorePlugin::BACKEND);
instance.setSettingsValue(QStringLiteral("Timeout"), 1, LOCAL_SETTING); instance.setSettingsValue(QStringLiteral("Timeout"), 1, LOCAL_SETTING);

View File

@ -16,7 +16,6 @@
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>. along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "snorenotify.h" #include "snorenotify.h"
#include "libsnore/log.h"
#include "libsnore/version.h" #include "libsnore/version.h"
#include <QApplication> #include <QApplication>

View File

@ -31,7 +31,7 @@ SnoreNotify::SnoreNotify()
SnoreCore::instance().loadPlugins(SnorePlugin::ALL); SnoreCore::instance().loadPlugins(SnorePlugin::ALL);
m_trayIcon->initConextMenu(); m_trayIcon->initConextMenu();
snoreDebug(SNORE_DEBUG) << "Snorenotfiy initialized with" << SnoreCore::instance().primaryNotificationBackend(); qCDebug(SNORE) << "Snorenotfiy initialized with" << SnoreCore::instance().primaryNotificationBackend();
} }
SnoreNotify::~SnoreNotify() SnoreNotify::~SnoreNotify()

View File

@ -58,7 +58,7 @@ void TrayIcon::initConextMenu()
m_settings->setVisible(false); m_settings->setVisible(false);
break; break;
default: default:
snoreDebug(SNORE_WARNING) << "unhandled role" << button->text() << box->buttonRole(button); qCWarning(SNORE) << "unhandled role" << button->text() << box->buttonRole(button);
} }
}); });
m_settings->layout()->addWidget(box); m_settings->layout()->addWidget(box);

View File

@ -29,7 +29,6 @@ list(APPEND SnoreNotify_SRCS
alert_p.cpp alert_p.cpp
hint.cpp hint.cpp
lambdahint.cpp lambdahint.cpp
log.cpp
settingsdialog.cpp settingsdialog.cpp
utils.cpp utils.cpp
${UI} ${UI}
@ -44,7 +43,6 @@ list(APPEND SnoreNotify_HDR
alert.h alert.h
hint.h hint.h
lambdahint.h lambdahint.h
log.h
settingsdialog.h settingsdialog.h
snoreglobals.h snoreglobals.h
utils.h utils.h

View File

@ -102,7 +102,7 @@ QDebug operator<< (QDebug debug, const Snore::Application &app)
{ {
if (app.isValid()) { if (app.isValid()) {
debug << "Snore::Application(" << app.name() << ", "; debug << "Snore::Application(" << app.name() << ", ";
foreach(const Alert & a, app.alerts()) { foreach (const Alert &a, app.alerts()) {
debug << a << ", "; debug << a << ", ";
} }
debug << ")" ; debug << ")" ;

View File

@ -17,7 +17,6 @@
*/ */
#include "hint.h" #include "hint.h"
#include "lambdahint.h" #include "lambdahint.h"
#include "log.h"
using namespace Snore; using namespace Snore;

View File

@ -1,96 +0,0 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2014-2015 Hannah von Reth <vonreth@kde.org>
SnoreNotify is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SnoreNotify is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/
#include "log.h"
#include <QApplication>
#include <QTime>
#include <QDir>
#include <QTextStream>
#include <iostream>
#include <memory>
#include <sstream>
using namespace Snore;
class LogData
{
public:
int debugLevel = 0;
QTextStream *logFile = nullptr;
QFile *file = nullptr;
LogData()
{
debugLevel = qgetenv("LIBSNORE_DEBUG_LVL").toInt();
if (qgetenv("LIBSNORE_LOG_TO_FILE").toInt() == 1) {
QString name = QDir::tempPath() + QStringLiteral("/libsnore/") +
(qApp->applicationName().isEmpty() ? QString::number(qApp->applicationPid()) : qApp->applicationName()) +
QLatin1String("-log.txt");
if (!qEnvironmentVariableIsSet("LIBSNORE_LOGFILE")) {
name = QString::fromUtf8(qgetenv("LIBSNORE_LOGFILE"));
} else {
QDir::temp().mkpath(QStringLiteral("libsnore"));
}
std::cout << "Started logging to " << name.toLocal8Bit().constData() << std::endl;
file = new QFile(name);
if (!file->open(QFile::WriteOnly)) {
qFatal("Failed to open log file %s", qPrintable(name));
}
logFile = new QTextStream(file);
}
}
~LogData()
{
delete logFile;
delete file;
}
};
Q_GLOBAL_STATIC(LogData, s_data)
SnoreLog::SnoreLog(SnoreDebugLevels lvl):
QDebug(&m_msg),
m_lvl(lvl)
{
}
SnoreLog::~SnoreLog()
{
QByteArray message = QTime::currentTime().toString(QStringLiteral("hh:mm:ss: ")).toUtf8().constData();
message.append(m_msg.toUtf8().constData());
if (s_data->logFile) {
*s_data->logFile << message.constData() << "\n";
s_data->logFile->flush();
}
if (m_lvl == SNORE_WARNING) {
std::wcerr << message.constData() << std::endl;
} else if (s_data->debugLevel >= m_lvl) {
std::wcout << message.constData() << std::endl;
}
}
void SnoreLog::setDebugLvl(int i)
{
s_data->debugLevel = i;
}

View File

@ -1,92 +0,0 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2014-2015 Hannah von Reth <vonreth@kde.org>
SnoreNotify is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SnoreNotify is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SNORELOG_H
#define SNORELOG_H
#include <QDebug>
#include "snore_exports.h"
/**
* @file
*/
/**
* SnoreDebugLevels enumerates all possible debugg levels.
*/
enum SnoreDebugLevels {
/**
* The most important messages, will be diplayed if the debug level >= 1
*/
SNORE_WARNING = 0,
/**
* Information messages, will be diplayed if the debug level >= 2
*/
SNORE_INFO = 1,
/**
* Debug messages will be diplayed if the debug level >= 3
*/
SNORE_DEBUG = 2
};
/**
* Logg macro use to logg messages.
* snoreDebug( SNORE_DEBUG ) << "Message" << notification;
*/
#if !defined(QT_NO_DEBUG_OUTPUT)
#define snoreDebug(X) Snore::SnoreLog( X ) << #X << Q_FUNC_INFO
#else
#define snoreDebug(X) QNoDebug()
#endif
namespace Snore
{
/**
* SnoreLog is a helper class to provide a logging system to Snore.
* @author Hannah von Reth \<vonreth at kde.org\>
*/
class SNORE_EXPORT SnoreLog : public QDebug
{
public:
/**
* Creates a debugg message whith a priority lvl.
* Use the snoreDebug(lvl) macro for logging.<br>
* snoreDebug( SNORE_DEBUG ) << "Message" << notification;
* @param lvl
*/
SnoreLog(SnoreDebugLevels lvl);
~SnoreLog();
/**
* Sets the debug threshold
* @param lvl the debug level
*/
static void setDebugLvl(int lvl);
private:
SnoreDebugLevels m_lvl;
QString m_msg;
};
}
#endif // SNORELOG_H

View File

@ -40,14 +40,14 @@ Icon Icon::defaultIcon()
Icon Icon::fromWebUrl(const QUrl &url, int maxTime) Icon Icon::fromWebUrl(const QUrl &url, int maxTime)
{ {
Icon icon = defaultIcon(); Icon icon = defaultIcon();
snoreDebug(SNORE_DEBUG) << url; qCDebug(SNORE) << url;
if (!s_downloadImageCache.contains(url)) { if (!s_downloadImageCache.contains(url)) {
snoreDebug(SNORE_DEBUG) << "Downloading:" << url; qCDebug(SNORE) << "Downloading:" << url;
QNetworkAccessManager *manager = new QNetworkAccessManager(); QNetworkAccessManager *manager = new QNetworkAccessManager();
QNetworkRequest request(url); QNetworkRequest request(url);
QNetworkReply *reply = manager->get(request); QNetworkReply *reply = manager->get(request);
QObject::connect(reply, &QNetworkReply::downloadProgress, [&](qint64 bytesReceived, qint64 bytesTotal) { QObject::connect(reply, &QNetworkReply::downloadProgress, [&](qint64 bytesReceived, qint64 bytesTotal) {
snoreDebug(SNORE_DEBUG) << "Downloading:" << url << bytesReceived / double(bytesTotal) * 100.0 << "%"; qCDebug(SNORE) << "Downloading:" << url << bytesReceived / double(bytesTotal) * 100.0 << "%";
}); });
QTime time; QTime time;
@ -56,16 +56,16 @@ Icon Icon::fromWebUrl(const QUrl &url, int maxTime)
qApp->processEvents(QEventLoop::AllEvents, maxTime); qApp->processEvents(QEventLoop::AllEvents, maxTime);
} }
if (reply->error() != QNetworkReply::NoError) { if (reply->error() != QNetworkReply::NoError) {
snoreDebug(SNORE_WARNING) << "Error downloading" << url << ":" << reply->errorString(); qCWarning(SNORE) << "Error downloading" << url << ":" << reply->errorString();
} else { } else {
if (reply->isFinished()) { if (reply->isFinished()) {
QPixmap pix; QPixmap pix;
pix.loadFromData(reply->readAll()); pix.loadFromData(reply->readAll());
icon = Icon(pix); icon = Icon(pix);
s_downloadImageCache.insert(url, icon); s_downloadImageCache.insert(url, icon);
snoreDebug(SNORE_DEBUG) << url << "added to cache."; qCDebug(SNORE) << url << "added to cache.";
} else { } else {
snoreDebug(SNORE_DEBUG) << "Download of " << url << "timed out."; qCDebug(SNORE) << "Download of " << url << "timed out.";
} }
} }
@ -74,7 +74,7 @@ Icon Icon::fromWebUrl(const QUrl &url, int maxTime)
manager->deleteLater(); manager->deleteLater();
} else { } else {
icon = s_downloadImageCache.value(url, defaultIcon()); icon = s_downloadImageCache.value(url, defaultIcon());
snoreDebug(SNORE_DEBUG) << url << "from cache"; qCDebug(SNORE) << url << "from cache";
} }
return icon; return icon;
} }

View File

@ -152,12 +152,12 @@ void Notification::addActiveIn(const QObject *o)
bool contains = d->m_activeIn.contains(o); bool contains = d->m_activeIn.contains(o);
Q_ASSERT_X(!contains, Q_FUNC_INFO, "already active"); Q_ASSERT_X(!contains, Q_FUNC_INFO, "already active");
if (contains) { if (contains) {
snoreDebug(SNORE_WARNING) << o << "already active in" << id(); qCWarning(SNORE) << o << "already active in" << id();
return; return;
} }
d->m_activeIn.insert(o); d->m_activeIn.insert(o);
SnoreCorePrivate::instance()->m_activeNotifications[id()] = *this; SnoreCorePrivate::instance()->m_activeNotifications[id()] = *this;
snoreDebug(SNORE_INFO) << SnoreCorePrivate::instance()->m_activeNotifications.size(); qCInfo(SNORE) << SnoreCorePrivate::instance()->m_activeNotifications.size();
} }
bool Notification::isActiveIn(const QObject *o) const bool Notification::isActiveIn(const QObject *o) const
@ -170,7 +170,7 @@ bool Notification::removeActiveIn(const QObject *o)
bool out = d->m_activeIn.remove(o); bool out = d->m_activeIn.remove(o);
if (d->m_activeIn.isEmpty()) { if (d->m_activeIn.isEmpty()) {
SnoreCorePrivate::instance()->m_activeNotifications.remove(id()); SnoreCorePrivate::instance()->m_activeNotifications.remove(id());
snoreDebug(SNORE_INFO) << SnoreCorePrivate::instance()->m_activeNotifications.size(); qCInfo(SNORE) << SnoreCorePrivate::instance()->m_activeNotifications.size();
} }
return out; return out;
} }

View File

@ -19,7 +19,6 @@
#include "notification/notification_p.h" #include "notification/notification_p.h"
#include "notification/icon.h" #include "notification/icon.h"
#include "../hint.h" #include "../hint.h"
#include "libsnore/log.h"
#include "libsnore/plugins/plugins.h" #include "libsnore/plugins/plugins.h"
#include "libsnore/snore.h" #include "libsnore/snore.h"
@ -44,8 +43,8 @@ NotificationData::NotificationData(const Snore::Application &application, const
m_hints(m_application.constHints()) m_hints(m_application.constHints())
{ {
notificationCount++; notificationCount++;
snoreDebug(SNORE_INFO) << "Creating Notification: ActiveNotifications" << notificationCount << "id" << m_id; qCInfo(SNORE) << "Creating Notification: ActiveNotifications" << notificationCount << "id" << m_id;
snoreDebug(SNORE_INFO) << title << text; qCInfo(SNORE) << title << text;
} }
Snore::NotificationData::NotificationData(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout, Notification::Prioritys priority): Snore::NotificationData::NotificationData(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout, Notification::Prioritys priority):
@ -61,15 +60,15 @@ Snore::NotificationData::NotificationData(const Notification &old, const QString
m_toReplace(old) m_toReplace(old)
{ {
notificationCount++; notificationCount++;
snoreDebug(SNORE_INFO) << "Creating Notification: ActiveNotifications" << notificationCount << "id" << m_id; qCInfo(SNORE) << "Creating Notification: ActiveNotifications" << notificationCount << "id" << m_id;
snoreDebug(SNORE_INFO) << title << text; qCInfo(SNORE) << title << text;
} }
NotificationData::~NotificationData() NotificationData::~NotificationData()
{ {
stopTimeoutTimer(); stopTimeoutTimer();
notificationCount--; notificationCount--;
snoreDebug(SNORE_INFO) << "Deleting Notification: ActiveNotifications" << notificationCount << "id" << m_id << "Close Reason:" << m_closeReason; qCInfo(SNORE) << "Deleting Notification: ActiveNotifications" << notificationCount << "id" << m_id << "Close Reason:" << m_closeReason;
} }
void NotificationData::setActionInvoked(const Snore::Action &action) void NotificationData::setActionInvoked(const Snore::Action &action)
@ -119,7 +118,7 @@ const SnorePlugin *NotificationData::source() const
bool NotificationData::sourceAndTargetAreSimilar(const SnorePlugin *target) bool NotificationData::sourceAndTargetAreSimilar(const SnorePlugin *target)
{ {
if (source() && source()->name() == target->name()) { if (source() && source()->name() == target->name()) {
snoreDebug(SNORE_DEBUG) << "Source" << source() << "and Target" << target << "are the same."; qCDebug(SNORE) << "Source" << source() << "and Target" << target << "are the same.";
return true; return true;
} }
return false; return false;

View File

@ -49,7 +49,7 @@ PluginContainer::~PluginContainer()
SnorePlugin *PluginContainer::load() SnorePlugin *PluginContainer::load()
{ {
if (!m_loader.isLoaded() && !m_loader.load()) { if (!m_loader.isLoaded() && !m_loader.load()) {
snoreDebug(SNORE_WARNING) << "Failed loading plugin: " << m_loader.errorString(); qCWarning(SNORE) << "Failed loading plugin: " << m_loader.errorString();
return nullptr; return nullptr;
} }
if (!m_plugin) { if (!m_plugin) {
@ -88,23 +88,23 @@ bool PluginContainer::isLoaded() const
void PluginContainer::updatePluginCache() void PluginContainer::updatePluginCache()
{ {
snoreDebug(SNORE_DEBUG) << "Updating plugin cache"; qCDebug(SNORE) << "Updating plugin cache";
foreach(PluginContaienrHash list, s_pluginCache.values()) { foreach (PluginContaienrHash list, s_pluginCache.values()) {
qDeleteAll(list); qDeleteAll(list);
list.clear(); list.clear();
} }
foreach(const SnorePlugin::PluginTypes type, SnorePlugin::types()) { foreach (const SnorePlugin::PluginTypes type, SnorePlugin::types()) {
foreach(const QFileInfo & file, pluginDir().entryInfoList( foreach (const QFileInfo &file, pluginDir().entryInfoList(
QStringList(pluginFileFilters(type)), QDir::Files)) { QStringList(pluginFileFilters(type)), QDir::Files)) {
snoreDebug(SNORE_DEBUG) << "adding" << file.absoluteFilePath(); qCDebug(SNORE) << "adding" << file.absoluteFilePath();
QPluginLoader loader(file.absoluteFilePath()); QPluginLoader loader(file.absoluteFilePath());
QJsonObject data = loader.metaData()[QStringLiteral("MetaData")].toObject(); QJsonObject data = loader.metaData()[QStringLiteral("MetaData")].toObject();
QString name = data.value(QStringLiteral("name")).toString(); QString name = data.value(QStringLiteral("name")).toString();
if (!name.isEmpty()) { if (!name.isEmpty()) {
PluginContainer *info = new PluginContainer(file.fileName(), name, type); PluginContainer *info = new PluginContainer(file.fileName(), name, type);
s_pluginCache[type].insert(name, info); s_pluginCache[type].insert(name, info);
snoreDebug(SNORE_DEBUG) << "added" << name << "to cache"; qCDebug(SNORE) << "added" << name << "to cache";
} }
} }
} }
@ -116,7 +116,7 @@ const QHash<QString, PluginContainer *> PluginContainer::pluginCache(SnorePlugin
QTime time; QTime time;
time.start(); time.start();
updatePluginCache(); updatePluginCache();
snoreDebug(SNORE_DEBUG) << "Plugins loaded in:" << time.elapsed(); qCDebug(SNORE) << "Plugins loaded in:" << time.elapsed();
} }
QHash<QString, PluginContainer *> out; QHash<QString, PluginContainer *> out;
@ -153,19 +153,19 @@ const QDir &PluginContainer::pluginDir()
<< appDir + suffix << appDir + suffix
<< appDir + QStringLiteral("/../lib/plugins") + suffix << appDir + QStringLiteral("/../lib/plugins") + suffix
<< appDir + QStringLiteral("/../lib64/plugins") + suffix; << appDir + QStringLiteral("/../lib64/plugins") + suffix;
foreach(const QString & p, list) { foreach (const QString &p, list) {
path = QDir(p); path = QDir(p);
if (!path.entryInfoList(pluginFileFilters()).isEmpty()) { if (!path.entryInfoList(pluginFileFilters()).isEmpty()) {
break; break;
} else { } else {
snoreDebug(SNORE_DEBUG) << "Possible pluginpath:" << path.absolutePath() << "does not contain plugins."; qCDebug(SNORE) << "Possible pluginpath:" << path.absolutePath() << "does not contain plugins.";
} }
} }
if (path.entryInfoList(pluginFileFilters()).isEmpty()) { if (path.entryInfoList(pluginFileFilters()).isEmpty()) {
snoreDebug(SNORE_WARNING) << "Couldnt find any plugins"; qCWarning(SNORE) << "Couldnt find any plugins";
} }
snoreDebug(SNORE_INFO) << "PluginPath is :" << path.absolutePath(); qCInfo(SNORE) << "PluginPath is :" << path.absolutePath();
} }
return path; return path;
} }

View File

@ -33,13 +33,13 @@ SnorePlugin::SnorePlugin()
{ {
Q_ASSERT_X(thread() == qApp->thread(), Q_FUNC_INFO, "Plugin initialized in wrong thread"); Q_ASSERT_X(thread() == qApp->thread(), Q_FUNC_INFO, "Plugin initialized in wrong thread");
if (thread() != qApp->thread()) { if (thread() != qApp->thread()) {
snoreDebug(SNORE_WARNING) << "Plugin initialized in wrong thread."; qCWarning(SNORE) << "Plugin initialized in wrong thread.";
} }
} }
SnorePlugin::~SnorePlugin() SnorePlugin::~SnorePlugin()
{ {
snoreDebug(SNORE_DEBUG) << name() << this << "deleted"; qCDebug(SNORE) << name() << this << "deleted";
} }
bool SnorePlugin::isEnabled() const bool SnorePlugin::isEnabled() const
@ -116,7 +116,7 @@ void SnorePlugin::setDefaultSettings()
void SnorePlugin::setErrorString(const QString &_error) void SnorePlugin::setErrorString(const QString &_error)
{ {
m_error = _error; m_error = _error;
snoreDebug(SNORE_WARNING) << name() << "encountered an error:" << m_error; qCWarning(SNORE) << name() << "encountered an error:" << m_error;
disable(); disable();
emit error(_error); emit error(_error);
} }

View File

@ -57,7 +57,7 @@ SnoreBackend::SnoreBackend()
SnoreBackend::~SnoreBackend() SnoreBackend::~SnoreBackend()
{ {
snoreDebug(SNORE_DEBUG) << "Deleting" << name(); qCDebug(SNORE) << "Deleting" << name();
} }
void SnoreBackend::requestCloseNotification(Notification notification, Notification::CloseReasons reason) void SnoreBackend::requestCloseNotification(Notification notification, Notification::CloseReasons reason)
@ -80,7 +80,7 @@ void SnoreBackend::closeNotification(Notification n, Notification::CloseReasons
n.old().removeActiveIn(this); n.old().removeActiveIn(this);
} }
n.data()->setCloseReason(reason); n.data()->setCloseReason(reason);
snoreDebug(SNORE_DEBUG) << n << reason; qCDebug(SNORE) << n << reason;
emit notificationClosed(n); emit notificationClosed(n);
} }

View File

@ -36,7 +36,7 @@ SnoreFrontend::SnoreFrontend()
SnoreFrontend::~SnoreFrontend() SnoreFrontend::~SnoreFrontend()
{ {
snoreDebug(SNORE_DEBUG) << "Deleting" << name(); qCDebug(SNORE) << "Deleting" << name();
} }
void SnoreFrontend::slotActionInvoked(Notification) void SnoreFrontend::slotActionInvoked(Notification)

View File

@ -37,7 +37,7 @@ SnoreSecondaryBackend::SnoreSecondaryBackend()
SnoreSecondaryBackend::~SnoreSecondaryBackend() SnoreSecondaryBackend::~SnoreSecondaryBackend()
{ {
snoreDebug(SNORE_DEBUG) << "Deleting" << name(); qCDebug(SNORE) << "Deleting" << name();
} }
void SnoreSecondaryBackend::slotNotify(Notification) void SnoreSecondaryBackend::slotNotify(Notification)

View File

@ -49,7 +49,7 @@ void SettingsDialog::initTabs()
bool enabled = false; bool enabled = false;
target->clear(); target->clear();
if (types & type) { if (types & type) {
foreach(PluginSettingsWidget * widget, SnoreCore::instance().settingWidgets(type)) { foreach (PluginSettingsWidget *widget, SnoreCore::instance().settingWidgets(type)) {
target->addTab(widget, widget->name()); target->addTab(widget, widget->name());
m_tabs.append(widget); m_tabs.append(widget);
enabled = true; enabled = true;
@ -88,11 +88,11 @@ void SettingsDialog::on_pushButton_clicked()
void SettingsDialog::load() void SettingsDialog::load()
{ {
snoreDebug(SNORE_DEBUG) << "loading"; qCDebug(SNORE) << "loading";
loadPrimaryBackendBox(SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString()); loadPrimaryBackendBox(SnoreCore::instance().settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString());
ui->timeoutSpinBox->setValue(SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LOCAL_SETTING).toInt()); ui->timeoutSpinBox->setValue(SnoreCore::instance().settingsValue(QStringLiteral("Timeout"), LOCAL_SETTING).toInt());
ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LOCAL_SETTING).toBool()); ui->disableNotificationSoundCheckBox->setChecked(SnoreCore::instance().settingsValue(QStringLiteral("Silent"), LOCAL_SETTING).toBool());
foreach(auto widget, m_tabs) { foreach (auto widget, m_tabs) {
widget->loadSettings(); widget->loadSettings();
} }
} }
@ -114,9 +114,9 @@ void SettingsDialog::loadPrimaryBackendBox(const QString &backend)
void SettingsDialog::save() void SettingsDialog::save()
{ {
snoreDebug(SNORE_DEBUG) << "saving"; qCDebug(SNORE) << "saving";
bool dirty = false; bool dirty = false;
foreach(auto w, m_tabs) { foreach (auto w, m_tabs) {
w->saveSettings(); w->saveSettings();
dirty |= w->isDirty(); dirty |= w->isDirty();
} }

View File

@ -34,6 +34,8 @@
using namespace Snore; using namespace Snore;
Q_LOGGING_CATEGORY(SNORE, "SNORE")
SnoreCore::SnoreCore(QObject *parent): SnoreCore::SnoreCore(QObject *parent):
QObject(parent) QObject(parent)
{ {
@ -69,16 +71,16 @@ SnoreCore::~SnoreCore()
void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types) void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
{ {
if (QThread::currentThread() != thread()) { if (QThread::currentThread() != thread()) {
snoreDebug(SNORE_DEBUG) << "Delayed Plugin loading." << QThread::currentThread() << thread(); qCDebug(SNORE) << "Delayed Plugin loading." << QThread::currentThread() << thread();
QMetaObject::invokeMethod(this, "loadPlugins", Qt::BlockingQueuedConnection, Q_ARG(Snore::SnorePlugin::PluginTypes, types)); QMetaObject::invokeMethod(this, "loadPlugins", Qt::BlockingQueuedConnection, Q_ARG(Snore::SnorePlugin::PluginTypes, types));
return; return;
} }
Q_D(SnoreCore); Q_D(SnoreCore);
setSettingsValue(QStringLiteral("PluginTypes"), QVariant::fromValue(types), LOCAL_SETTING); setSettingsValue(QStringLiteral("PluginTypes"), QVariant::fromValue(types), LOCAL_SETTING);
snoreDebug(SNORE_DEBUG) << "Loading plugin types:" << types; qCDebug(SNORE) << "Loading plugin types:" << types;
foreach(const SnorePlugin::PluginTypes type, SnorePlugin::types()) { foreach (const SnorePlugin::PluginTypes type, SnorePlugin::types()) {
if (type != SnorePlugin::ALL && types & type) { if (type != SnorePlugin::ALL && types & type) {
foreach(PluginContainer * info, PluginContainer::pluginCache(type).values()) { foreach (PluginContainer *info, PluginContainer::pluginCache(type).values()) {
SnorePlugin *plugin = info->load(); SnorePlugin *plugin = info->load();
if (!plugin) { if (!plugin) {
continue; continue;
@ -93,11 +95,11 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
plugin->setEnabled(plugin->settingsValue(QStringLiteral("Enabled"), LOCAL_SETTING).toBool()); plugin->setEnabled(plugin->settingsValue(QStringLiteral("Enabled"), LOCAL_SETTING).toBool());
break; break;
default: default:
snoreDebug(SNORE_WARNING) << "Plugin Cache corrupted\n" << info->file() << info->type(); qCWarning(SNORE) << "Plugin Cache corrupted\n" << info->file() << info->type();
continue; continue;
} }
snoreDebug(SNORE_DEBUG) << info->name() << "is a" << info->type(); qCDebug(SNORE) << info->name() << "is a" << info->type();
d->m_pluginNames[info->type()].append(info->name()); d->m_pluginNames[info->type()].append(info->name());
auto key = qMakePair(type, info->name()); auto key = qMakePair(type, info->name());
Q_ASSERT_X(!d->m_plugins.contains(key), Q_FUNC_INFO, "Multiple plugins of the same type with the same name."); Q_ASSERT_X(!d->m_plugins.contains(key), Q_FUNC_INFO, "Multiple plugins of the same type with the same name.");
@ -109,19 +111,19 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
} }
} }
d->slotInitPrimaryNotificationBackend(); d->slotInitPrimaryNotificationBackend();
snoreDebug(SNORE_INFO) << "Loaded Plugins:" << d->m_pluginNames; qCInfo(SNORE) << "Loaded Plugins:" << d->m_pluginNames;
} }
void SnoreCore::broadcastNotification(Notification notification) void SnoreCore::broadcastNotification(Notification notification)
{ {
Q_D(SnoreCore); Q_D(SnoreCore);
if (d->m_activeNotifications.size() > d->maxNumberOfActiveNotifications()) { if (d->m_activeNotifications.size() > d->maxNumberOfActiveNotifications()) {
snoreDebug(SNORE_DEBUG) << "queue size:" << d->m_notificationQue.size() << "active size:" << d->m_activeNotifications.size(); qCDebug(SNORE) << "queue size:" << d->m_notificationQue.size() << "active size:" << d->m_activeNotifications.size();
d->m_notificationQue.append(notification); d->m_notificationQue.append(notification);
return; return;
} }
Q_ASSERT_X(!notification.data()->isBroadcasted(), Q_FUNC_INFO, "Notification was already broadcasted."); Q_ASSERT_X(!notification.data()->isBroadcasted(), Q_FUNC_INFO, "Notification was already broadcasted.");
snoreDebug(SNORE_DEBUG) << "Broadcasting" << notification << "timeout:" << notification.timeout(); qCDebug(SNORE) << "Broadcasting" << notification << "timeout:" << notification.timeout();
if (d->m_notificationBackend != nullptr) { if (d->m_notificationBackend != nullptr) {
if (notification.isUpdate() && !d->m_notificationBackend->canUpdateNotification()) { if (notification.isUpdate() && !d->m_notificationBackend->canUpdateNotification()) {
requestCloseNotification(notification.old(), Notification::REPLACED); requestCloseNotification(notification.old(), Notification::REPLACED);
@ -140,7 +142,7 @@ void SnoreCore::registerApplication(const Application &application)
Q_D(SnoreCore); Q_D(SnoreCore);
Q_ASSERT_X(!d->m_applications.contains(application.key()), Q_FUNC_INFO, Q_ASSERT_X(!d->m_applications.contains(application.key()), Q_FUNC_INFO,
"Applications mus be registered only once."); "Applications mus be registered only once.");
snoreDebug(SNORE_DEBUG) << "Registering Application:" << application; qCDebug(SNORE) << "Registering Application:" << application;
d->m_applications.insert(application.key(), application); d->m_applications.insert(application.key(), application);
emit d->applicationRegistered(application); emit d->applicationRegistered(application);
} }
@ -190,7 +192,7 @@ void SnoreCore::requestCloseNotification(Notification n, Notification::CloseReas
Q_D(SnoreCore); Q_D(SnoreCore);
bool wasQued = d->m_notificationQue.removeOne(n); bool wasQued = d->m_notificationQue.removeOne(n);
if (wasQued) { if (wasQued) {
snoreDebug(SNORE_DEBUG) << n << " was qued."; qCDebug(SNORE) << n << " was qued.";
} }
if (!wasQued && d->m_notificationBackend) { if (!wasQued && d->m_notificationBackend) {
d->m_notificationBackend->requestCloseNotification(n, r); d->m_notificationBackend->requestCloseNotification(n, r);
@ -212,7 +214,7 @@ QList<PluginSettingsWidget *> SnoreCore::settingWidgets(SnorePlugin::PluginTypes
{ {
Q_D(SnoreCore); Q_D(SnoreCore);
QList<PluginSettingsWidget *> list; QList<PluginSettingsWidget *> list;
foreach(const QString & name, d->m_pluginNames[type]) { foreach (const QString &name, d->m_pluginNames[type]) {
//TODO: mem leak? //TODO: mem leak?
SnorePlugin *p = d->m_plugins[qMakePair(type, name)]; SnorePlugin *p = d->m_plugins[qMakePair(type, name)];
PluginSettingsWidget *widget = p->settingsWidget(); PluginSettingsWidget *widget = p->settingsWidget();
@ -247,7 +249,7 @@ void SnoreCore::setDefaultSettingsValue(const QString &key, const QVariant &valu
Q_D(SnoreCore); Q_D(SnoreCore);
QString nk = d->normalizeSettingsKey(key, type); QString nk = d->normalizeSettingsKey(key, type);
if (!d->m_settings->contains(nk)) { if (!d->m_settings->contains(nk)) {
snoreDebug(SNORE_DEBUG) << "Set default value" << nk << value; qCDebug(SNORE) << "Set default value" << nk << value;
d->m_settings->setValue(nk, value); d->m_settings->setValue(nk, value);
} }
} }

View File

@ -21,7 +21,6 @@
#include "snore_exports.h" #include "snore_exports.h"
#include "snoreglobals.h" #include "snoreglobals.h"
#include "log.h"
#include "application.h" #include "application.h"
#include "notification/notification.h" #include "notification/notification.h"
#include "plugins/plugins.h" #include "plugins/plugins.h"

View File

@ -34,19 +34,19 @@ using namespace Snore;
SnoreCorePrivate::SnoreCorePrivate(): SnoreCorePrivate::SnoreCorePrivate():
m_localSettingsPrefix(qApp->applicationName().isEmpty() ? QStringLiteral("SnoreNotify") : qApp->applicationName()) m_localSettingsPrefix(qApp->applicationName().isEmpty() ? QStringLiteral("SnoreNotify") : qApp->applicationName())
{ {
if (!qEnvironmentVariableIsSet("LIBSNORE_SETTINGS_FILE")) { if (qEnvironmentVariableIsSet("LIBSNORE_SETTINGS_FILE")) {
m_settings = new QSettings(QString::fromUtf8(qgetenv("LIBSNORE_SETTINGS_FILE")), QSettings::IniFormat); m_settings = new QSettings(QString::fromUtf8(qgetenv("LIBSNORE_SETTINGS_FILE")), QSettings::IniFormat);
} else { } else {
m_settings = new QSettings(QStringLiteral("Snorenotify"), QStringLiteral("libsnore"), this); m_settings = new QSettings(QStringLiteral("Snorenotify"), QStringLiteral("libsnore"), this);
} }
snoreDebug(SNORE_INFO) << "Version:" << Version::version(); qCInfo(SNORE) << "Version:" << Version::version();
if (!Version::revision().isEmpty()) { if (!Version::revision().isEmpty()) {
snoreDebug(SNORE_INFO) << "Revision:" << Version::revision(); qCInfo(SNORE) << "Revision:" << Version::revision();
} }
snoreDebug(SNORE_DEBUG) << "Temp dir is" << tempPath(); qCDebug(SNORE) << "Temp dir is" << tempPath();
snoreDebug(SNORE_DEBUG) << "Snore settings are located in" << m_settings->fileName(); qCDebug(SNORE) << "Snore settings are located in" << m_settings->fileName();
snoreDebug(SNORE_DEBUG) << "Snore local settings are located in" << normalizeSettingsKey(QStringLiteral("Test"), LOCAL_SETTING); qCDebug(SNORE) << "Snore local settings are located in" << normalizeSettingsKey(QStringLiteral("Test"), LOCAL_SETTING);
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAboutToQuit())); connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAboutToQuit()));
} }
@ -85,13 +85,13 @@ bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend)
} }
const QHash<QString, PluginContainer *> backends = PluginContainer::pluginCache(SnorePlugin::BACKEND); const QHash<QString, PluginContainer *> backends = PluginContainer::pluginCache(SnorePlugin::BACKEND);
if (!backends.contains(backend)) { if (!backends.contains(backend)) {
snoreDebug(SNORE_DEBUG) << "Unknown Backend:" << backend; qCDebug(SNORE) << "Unknown Backend:" << backend;
return false; return false;
} }
snoreDebug(SNORE_DEBUG) << "Setting Notification Backend to:" << backend; qCDebug(SNORE) << "Setting Notification Backend to:" << backend;
SnoreBackend *b = qobject_cast<SnoreBackend *>(backends.value(backend)->load()); SnoreBackend *b = qobject_cast<SnoreBackend *>(backends.value(backend)->load());
if (!b->isReady()) { if (!b->isReady()) {
snoreDebug(SNORE_DEBUG) << "Backend not ready:" << b->errorString(); qCDebug(SNORE) << "Backend not ready:" << b->errorString();
emit q->primaryNotificationBackendError(b->errorString()); emit q->primaryNotificationBackendError(b->errorString());
return false; return false;
@ -115,7 +115,7 @@ bool SnoreCorePrivate::setBackendIfAvailible(const QString &backend)
bool SnoreCorePrivate::slotInitPrimaryNotificationBackend() bool SnoreCorePrivate::slotInitPrimaryNotificationBackend()
{ {
Q_Q(SnoreCore); Q_Q(SnoreCore);
snoreDebug(SNORE_DEBUG) << q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString(); qCDebug(SNORE) << q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString();
if (setBackendIfAvailible(q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString())) { if (setBackendIfAvailible(q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString())) {
return true; return true;
} }
@ -174,15 +174,15 @@ void SnoreCorePrivate::syncSettings()
m_notificationBackend = nullptr; m_notificationBackend = nullptr;
} }
if (!setBackendIfAvailible(newBackend)) { if (!setBackendIfAvailible(newBackend)) {
snoreDebug(SNORE_WARNING) << "Failed to set new backend" << q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString() << "restoring" << oldBackend; qCWarning(SNORE) << "Failed to set new backend" << q->settingsValue(QStringLiteral("PrimaryBackend"), LOCAL_SETTING).toString() << "restoring" << oldBackend;
setBackendIfAvailible(oldBackend); setBackendIfAvailible(oldBackend);
} }
} }
auto types = SnorePlugin::types(); auto types = SnorePlugin::types();
types.removeOne(SnorePlugin::BACKEND); types.removeOne(SnorePlugin::BACKEND);
foreach(auto type, types) { foreach (auto type, types) {
foreach(auto & pluginName, m_pluginNames[type]) { foreach (auto &pluginName, m_pluginNames[type]) {
auto key = qMakePair(type, pluginName); auto key = qMakePair(type, pluginName);
SnorePlugin *plugin = m_plugins.value(key); SnorePlugin *plugin = m_plugins.value(key);
bool enable = m_plugins[key]->settingsValue(QStringLiteral("Enabled"), LOCAL_SETTING).toBool(); bool enable = m_plugins[key]->settingsValue(QStringLiteral("Enabled"), LOCAL_SETTING).toBool();
@ -229,10 +229,10 @@ void SnoreCorePrivate::slotNotificationClosed(Notification n)
Q_Q(SnoreCore); Q_Q(SnoreCore);
emit q->notificationClosed(n); emit q->notificationClosed(n);
if (!n.removeActiveIn(q)) { if (!n.removeActiveIn(q)) {
snoreDebug(SNORE_WARNING) << n << "was already closed"; qCWarning(SNORE) << n << "was already closed";
} }
if (!m_notificationQue.isEmpty() && m_activeNotifications.size() < maxNumberOfActiveNotifications()) { if (!m_notificationQue.isEmpty() && m_activeNotifications.size() < maxNumberOfActiveNotifications()) {
snoreDebug(SNORE_DEBUG) << "Broadcast from queue" << m_notificationQue.size(); qCDebug(SNORE) << "Broadcast from queue" << m_notificationQue.size();
q->broadcastNotification(m_notificationQue.takeFirst()); q->broadcastNotification(m_notificationQue.takeFirst());
} }
} }
@ -241,7 +241,7 @@ void SnoreCorePrivate::slotAboutToQuit()
{ {
for (PluginContainer *p : PluginContainer::pluginCache(SnorePlugin::ALL)) { for (PluginContainer *p : PluginContainer::pluginCache(SnorePlugin::ALL)) {
if (p->isLoaded()) { if (p->isLoaded()) {
snoreDebug(SNORE_DEBUG) << "deinitialize" << p->name(); qCDebug(SNORE) << "deinitialize" << p->name();
p->load()->disable(); p->load()->disable();
} }
} }
@ -264,7 +264,7 @@ void SnoreCorePrivate::startNotificationTimeoutTimer(Notification notification)
} }
timer->setInterval(notification.timeout() * 1000); timer->setInterval(notification.timeout() * 1000);
connect(timer, &QTimer::timeout, [q, notification]() { connect(timer, &QTimer::timeout, [q, notification]() {
snoreDebug(SNORE_DEBUG) << notification; qCDebug(SNORE) << notification;
q->requestCloseNotification(notification, Notification::TIMED_OUT); q->requestCloseNotification(notification, Notification::TIMED_OUT);
}); });
timer->start(); timer->start();

View File

@ -19,6 +19,8 @@
#ifndef SNOREGLOBALS #ifndef SNOREGLOBALS
#define SNOREGLOBALS #define SNOREGLOBALS
#include <QLoggingCategory>
namespace Snore namespace Snore
{ {
@ -29,5 +31,7 @@ enum SettingsType {
} }
Q_DECLARE_LOGGING_CATEGORY(SNORE)
#endif // SNOREGLOBALS #endif // SNOREGLOBALS

View File

@ -16,7 +16,6 @@
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>. along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "utils.h" #include "utils.h"
#include "log.h"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <windows.h> #include <windows.h>
@ -76,60 +75,60 @@ void Utils::raiseWindowToFront(qlonglong wid)
static QRegExp regexp(QLatin1String(PATTERN));\ static QRegExp regexp(QLatin1String(PATTERN));\
STRING = STRING.replace(regexp, QStringLiteral("\\1"));\ STRING = STRING.replace(regexp, QStringLiteral("\\1"));\
}\ }\
QString Utils::normalizeMarkup(QString string, MARKUP_FLAGS tags) QString Utils::normalizeMarkup(QString string, MARKUP_FLAGS tags)
{ {
static QMutex mutex; static QMutex mutex;
if (tags == ALL_MARKUP) { if (tags == ALL_MARKUP) {
return string;
} else if (tags == NO_MARKUP) {
return QTextDocumentFragment::fromHtml(string).toPlainText();
}
QMutexLocker lock(&mutex);
if (~tags & Utils::BREAK) {
static QRegExp br(QLatin1String("<br>"));
string = string.replace(br, QStringLiteral("\n"));
}
if (~tags & Utils::HREF) {
HTML_REPLACE(string, "<a href=.*>([^<]*)</a>");
}
if (~tags & Utils::ITALIC) {
HTML_REPLACE(string, "<i>([^<]*)</i>");
}
if (~tags & Utils::BOLD) {
HTML_REPLACE(string, "<b>([^<]*)</b>");
}
if (~tags & Utils::UNDERLINE) {
HTML_REPLACE(string, "<u>([^<]*)</u>");
}
if (~tags & Utils::FONT) {
HTML_REPLACE(string, "<font.*>([^<]*)</font>");
}
return string; return string;
} else if (tags == NO_MARKUP) {
return QTextDocumentFragment::fromHtml(string).toPlainText();
} }
QMutexLocker lock(&mutex); QByteArray Utils::dataFromImage(const QImage &image)
if (~tags & Utils::BREAK) { {
static QRegExp br(QLatin1String("<br>")); QByteArray data;
string = string.replace(br, QStringLiteral("\n")); QBuffer buffer(&data);
buffer.open(QBuffer::WriteOnly);
image.save(&buffer, "PNG");
return data;
} }
if (~tags & Utils::HREF) {
HTML_REPLACE(string, "<a href=.*>([^<]*)</a>");
}
if (~tags & Utils::ITALIC) {
HTML_REPLACE(string, "<i>([^<]*)</i>");
}
if (~tags & Utils::BOLD) {
HTML_REPLACE(string, "<b>([^<]*)</b>");
}
if (~tags & Utils::UNDERLINE) {
HTML_REPLACE(string, "<u>([^<]*)</u>");
}
if (~tags & Utils::FONT) {
HTML_REPLACE(string, "<font.*>([^<]*)</font>");
}
return string;
}
QByteArray Utils::dataFromImage(const QImage &image)
{
QByteArray data;
QBuffer buffer(&data);
buffer.open(QBuffer::WriteOnly);
image.save(&buffer, "PNG");
return data;
}
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
int Utils::attatchToActiveProcess() int Utils::attatchToActiveProcess()
{ {
int idActive = GetWindowThreadProcessId(GetForegroundWindow(), NULL); int idActive = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
return AttachThreadInput(GetCurrentThreadId(), idActive, TRUE) ? idActive : -1; return AttachThreadInput(GetCurrentThreadId(), idActive, TRUE) ? idActive : -1;
} }
void Utils::detatchActiveProcess(int idActive) void Utils::detatchActiveProcess(int idActive)
{ {
if (idActive != -1) { if (idActive != -1) {
AttachThreadInput(GetCurrentThreadId(), idActive, FALSE); AttachThreadInput(GetCurrentThreadId(), idActive, FALSE);
}
} }
}
#endif #endif

View File

@ -50,7 +50,7 @@ void FreedesktopBackend::slotNotify(Notification noti)
} }
QStringList actions; QStringList actions;
foreach(int k, noti.actions().keys()) { foreach (int k, noti.actions().keys()) {
actions << QString::number(k) << noti.actions()[k].name(); actions << QString::number(k) << noti.actions()[k].name();
} }
QVariantMap hints; QVariantMap hints;
@ -89,12 +89,12 @@ void FreedesktopBackend::slotNotify(Notification noti)
m_dbusIdMap[id.value()] = noti; m_dbusIdMap[id.value()] = noti;
slotNotificationDisplayed(noti); slotNotificationDisplayed(noti);
snoreDebug(SNORE_DEBUG) << noti.id() << "|" << id.value(); qCDebug(SNORE) << noti.id() << "|" << id.value();
} }
void FreedesktopBackend::slotActionInvoked(const uint &id, const QString &actionID) void FreedesktopBackend::slotActionInvoked(const uint &id, const QString &actionID)
{ {
snoreDebug(SNORE_DEBUG) << id << m_dbusIdMap[id]; qCDebug(SNORE) << id << m_dbusIdMap[id];
Notification noti = m_dbusIdMap[id]; Notification noti = m_dbusIdMap[id];
if (!noti.isValid()) { if (!noti.isValid()) {
return; return;
@ -105,7 +105,7 @@ void FreedesktopBackend::slotActionInvoked(const uint &id, const QString &action
void FreedesktopBackend::slotCloseNotification(Notification notification) void FreedesktopBackend::slotCloseNotification(Notification notification)
{ {
uint id = notification.hints().privateValue(this, "id").toUInt(); uint id = notification.hints().privateValue(this, "id").toUInt();
snoreDebug(SNORE_DEBUG) << notification.id() << id; qCDebug(SNORE) << notification.id() << id;
m_interface->CloseNotification(id); m_interface->CloseNotification(id);
} }
@ -138,7 +138,7 @@ void FreedesktopBackend::slotNotificationClosed(const uint &id, const uint &reas
closeReason = Notification::NONE; closeReason = Notification::NONE;
} }
snoreDebug(SNORE_DEBUG) << id << "|" << closeReason << reason; qCDebug(SNORE) << id << "|" << closeReason << reason;
if (id == 0) { if (id == 0) {
return; return;
} }

View File

@ -105,12 +105,12 @@ void FreedesktopBackend::slotNotify(Notification noti)
m_dbusIdMap[id.value()] = noti; m_dbusIdMap[id.value()] = noti;
slotNotificationDisplayed(noti); slotNotificationDisplayed(noti);
snoreDebug(SNORE_DEBUG) << noti.id() << "|" << id.value(); qCDebug(SNORE) << noti.id() << "|" << id.value();
} }
void FreedesktopBackend::slotActionInvoked(const uint &id, const QString &actionID) void FreedesktopBackend::slotActionInvoked(const uint &id, const QString &actionID)
{ {
snoreDebug(SNORE_DEBUG) << id << m_dbusIdMap[id]; qCDebug(SNORE) << id << m_dbusIdMap[id];
Notification noti = m_dbusIdMap[id]; Notification noti = m_dbusIdMap[id];
if (!noti.isValid()) { if (!noti.isValid()) {
return; return;
@ -121,7 +121,7 @@ void FreedesktopBackend::slotActionInvoked(const uint &id, const QString &action
void FreedesktopBackend::slotCloseNotification(Notification notification) void FreedesktopBackend::slotCloseNotification(Notification notification)
{ {
uint id = notification.hints().privateValue(this, "id").toUInt(); uint id = notification.hints().privateValue(this, "id").toUInt();
snoreDebug(SNORE_DEBUG) << notification.id() << id; qCDebug(SNORE) << notification.id() << id;
m_interface->CloseNotification(id); m_interface->CloseNotification(id);
} }
@ -154,7 +154,7 @@ void FreedesktopBackend::slotNotificationClosed(const uint &id, const uint &reas
closeReason = Notification::NONE; closeReason = Notification::NONE;
} }
snoreDebug(SNORE_DEBUG) << id << "|" << closeReason << reason; qCDebug(SNORE) << id << "|" << closeReason << reason;
if (id == 0) { if (id == 0) {
return; return;
} }

View File

@ -34,7 +34,7 @@ GrowlBackend::GrowlBackend()
s_instance = this; s_instance = this;
auto func = [](growl_callback_data * data)->void { auto func = [](growl_callback_data * data)->void {
snoreDebug(SNORE_DEBUG) << data->id << QString::fromUtf8(data->reason) << QString::fromUtf8(data->data); qCDebug(SNORE) << data->id << QString::fromUtf8(data->reason) << QString::fromUtf8(data->data);
Notification n = Snore::SnoreCore::instance().getActiveNotificationByID(data->id); Notification n = Snore::SnoreCore::instance().getActiveNotificationByID(data->id);
if (!n.isValid()) if (!n.isValid())
{ {
@ -74,10 +74,10 @@ bool GrowlBackend::isReady()
void GrowlBackend::slotRegisterApplication(const Application &application) void GrowlBackend::slotRegisterApplication(const Application &application)
{ {
snoreDebug(SNORE_DEBUG) << application.name(); qCDebug(SNORE) << application.name();
std::vector<std::string> alerts; std::vector<std::string> alerts;
foreach(const Alert & a, application.alerts()) { foreach (const Alert &a, application.alerts()) {
snoreDebug(SNORE_DEBUG) << a.name(); qCDebug(SNORE) << a.name();
alerts.push_back(a.name().toUtf8().constData()); alerts.push_back(a.name().toUtf8().constData());
} }
@ -102,7 +102,7 @@ void GrowlBackend::slotNotify(Notification notification)
{ {
Growl *growl = m_applications.value(notification.application().name()); Growl *growl = m_applications.value(notification.application().name());
QString alert = notification.alert().name(); QString alert = notification.alert().name();
snoreDebug(SNORE_DEBUG) << "Notify Growl:" << notification.application() << alert << notification.title(); qCDebug(SNORE) << "Notify Growl:" << notification.application() << alert << notification.title();
GrowlNotificationData data(alert.toUtf8().constData(), notification.id(), GrowlNotificationData data(alert.toUtf8().constData(), notification.id(),
notification.title().toUtf8().constData(), notification.title().toUtf8().constData(),

View File

@ -68,11 +68,11 @@ BOOL installNSBundleHook()
- (void) userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification - (void) userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
{ {
snoreDebug(SNORE_DEBUG) << "User clicked on notification"; qCDebug(SNORE) << "User clicked on notification";
int notificationId = [notification.userInfo[@"id"] intValue]; int notificationId = [notification.userInfo[@"id"] intValue];
[center removeDeliveredNotification: notification]; [center removeDeliveredNotification: notification];
if (not m_IdToNotification.contains(notificationId)) { if (not m_IdToNotification.contains(notificationId)) {
snoreDebug(SNORE_WARNING) << "User clicked on notification that was not recognized"; qCWarning(SNORE) << "User clicked on notification that was not recognized";
return; return;
} }
auto snoreNotification = m_IdToNotification.take(notificationId); auto snoreNotification = m_IdToNotification.take(notificationId);

View File

@ -70,40 +70,40 @@ public:
switch (action) { switch (action) {
case SnarlEnums::CallbackInvoked: case SnarlEnums::CallbackInvoked:
reason = Notification::ACTIVATED; reason = Notification::ACTIVATED;
snoreDebug(SNORE_DEBUG) << "Notification clicked"; qCDebug(SNORE) << "Notification clicked";
break; break;
case SnarlEnums::NotifyAction: case SnarlEnums::NotifyAction:
reason = Notification::ACTIVATED; reason = Notification::ACTIVATED;
snoreDebug(SNORE_DEBUG) << "Notification action invoked"; qCDebug(SNORE) << "Notification action invoked";
if (notification.isValid()) { if (notification.isValid()) {
m_snarl->slotNotificationActionInvoked(notification, notification.actions().value(data)); m_snarl->slotNotificationActionInvoked(notification, notification.actions().value(data));
} }
break; break;
case SnarlEnums::CallbackClosed: case SnarlEnums::CallbackClosed:
reason = Notification::DISMISSED; reason = Notification::DISMISSED;
snoreDebug(SNORE_DEBUG) << "Notification dismissed"; qCDebug(SNORE) << "Notification dismissed";
break; break;
case SnarlEnums::CallbackTimedOut: case SnarlEnums::CallbackTimedOut:
reason = Notification::TIMED_OUT; reason = Notification::TIMED_OUT;
snoreDebug(SNORE_DEBUG) << "Notification timed out"; qCDebug(SNORE) << "Notification timed out";
break; break;
//away stuff //away stuff
case SnarlEnums::SnarlUserAway: case SnarlEnums::SnarlUserAway:
snoreDebug(SNORE_DEBUG) << "Snalr user has gone away"; qCDebug(SNORE) << "Snalr user has gone away";
return true; return true;
case SnarlEnums::SnarlUserBack: case SnarlEnums::SnarlUserBack:
snoreDebug(SNORE_DEBUG) << "Snalr user has returned"; qCDebug(SNORE) << "Snalr user has returned";
return true; return true;
default: default:
snoreDebug(SNORE_WARNING) << "Unknown snarl action found!!"; qCWarning(SNORE) << "Unknown snarl action found!!";
return false; return false;
} }
if (notification.isValid()) { if (notification.isValid()) {
m_snarl->requestCloseNotification(notification, reason); m_snarl->requestCloseNotification(notification, reason);
m_snarl->m_idMap.take(msg->lParam); m_snarl->m_idMap.take(msg->lParam);
} else { } else {
snoreDebug(SNORE_WARNING) << "Snarl notification already closed" << msg->lParam << action; qCWarning(SNORE) << "Snarl notification already closed" << msg->lParam << action;
snoreDebug(SNORE_WARNING) << m_snarl->m_idMap; qCWarning(SNORE) << m_snarl->m_idMap;
} }
return true; return true;
} }
@ -177,9 +177,9 @@ void SnarlBackend::slotRegisterApplication(const Application &application)
application.icon().localUrl(QSize(128, 128)).toUtf8().constData(), application.icon().localUrl(QSize(128, 128)).toUtf8().constData(),
password.isEmpty() ? 0 : password.toUtf8().constData(), password.isEmpty() ? 0 : password.toUtf8().constData(),
(HWND)m_eventLoop->winId(), SNORENOTIFIER_MESSAGE_ID); (HWND)m_eventLoop->winId(), SNORENOTIFIER_MESSAGE_ID);
snoreDebug(SNORE_DEBUG) << result; qCDebug(SNORE) << result;
foreach(const Alert & alert, application.alerts()) { foreach (const Alert &alert, application.alerts()) {
snarlInterface->AddClass(alert.name().toUtf8().constData(), snarlInterface->AddClass(alert.name().toUtf8().constData(),
alert.name().toUtf8().constData(), alert.name().toUtf8().constData(),
0, 0, alert.icon().localUrl(QSize(128, 128)).toUtf8().constData()); 0, 0, alert.icon().localUrl(QSize(128, 128)).toUtf8().constData());
@ -189,7 +189,7 @@ void SnarlBackend::slotRegisterApplication(const Application &application)
void SnarlBackend::slotDeregisterApplication(const Application &application) void SnarlBackend::slotDeregisterApplication(const Application &application)
{ {
if (!m_applications.contains(application.name())) { if (!m_applications.contains(application.name())) {
snoreDebug(SNORE_DEBUG) << "Unknown apllication: " << application.name(); qCDebug(SNORE) << "Unknown apllication: " << application.name();
return; return;
} }
SnarlInterface *snarlInterface = m_applications.take(application.name()); SnarlInterface *snarlInterface = m_applications.take(application.name());
@ -201,7 +201,7 @@ void SnarlBackend::slotDeregisterApplication(const Application &application)
void SnarlBackend::slotNotify(Notification notification) void SnarlBackend::slotNotify(Notification notification)
{ {
if (!m_applications.contains(notification.application().name())) { if (!m_applications.contains(notification.application().name())) {
snoreDebug(SNORE_DEBUG) << "Unknown apllication: " << notification.application().name(); qCDebug(SNORE) << "Unknown apllication: " << notification.application().name();
return; return;
} }
@ -217,7 +217,7 @@ void SnarlBackend::slotNotify(Notification notification)
} }
ULONG32 id = 0; ULONG32 id = 0;
snoreDebug(SNORE_DEBUG) << notification.icon(); qCDebug(SNORE) << notification.icon();
if (!notification.isUpdate()) { if (!notification.isUpdate()) {
id = snarlInterface->Notify(notification.alert().name().toUtf8().constData(), id = snarlInterface->Notify(notification.alert().name().toUtf8().constData(),
@ -228,7 +228,7 @@ void SnarlBackend::slotNotify(Notification notification)
Utils::dataFromImage(notification.icon().pixmap(QSize(128, 128)).toImage()).toBase64().constData(), Utils::dataFromImage(notification.icon().pixmap(QSize(128, 128)).toImage()).toBase64().constData(),
priority); priority);
foreach(const Action & a, notification.actions()) { foreach (const Action &a, notification.actions()) {
snarlInterface->AddAction(id, a.name().toUtf8().constData(), (QLatin1Char('@') + QString::number(a.id())).toUtf8().constData()); snarlInterface->AddAction(id, a.name().toUtf8().constData(), (QLatin1Char('@') + QString::number(a.id())).toUtf8().constData());
} }
m_idMap[id] = notification; m_idMap[id] = notification;
@ -254,7 +254,7 @@ void SnarlBackend::slotNotify(Notification notification)
void SnarlBackend::slotCloseNotification(Notification notification) void SnarlBackend::slotCloseNotification(Notification notification)
{ {
if (!m_applications.contains(notification.application().name())) { if (!m_applications.contains(notification.application().name())) {
snoreDebug(SNORE_DEBUG) << "Unknown apllication: " << notification.application().name(); qCDebug(SNORE) << "Unknown apllication: " << notification.application().name();
return; return;
} }
ULONG32 id = notification.hints().privateValue(this, "id").toUInt(); ULONG32 id = notification.hints().privateValue(this, "id").toUInt();

View File

@ -18,7 +18,6 @@
#include "notifywidget.h" #include "notifywidget.h"
#include "snorenotifier.h" #include "snorenotifier.h"
#include "libsnore/log.h"
#include "libsnore/utils.h" #include "libsnore/utils.h"
#include <QApplication> #include <QApplication>
@ -68,13 +67,13 @@ NotifyWidget::NotifyWidget(int id, const SnoreNotifier *parent) :
m_mem.unlock(); m_mem.unlock();
} else { } else {
if (!m_mem.attach()) { if (!m_mem.attach()) {
snoreDebug(SNORE_WARNING) << "Failed to atatche to shared mem"; qCWarning(SNORE) << "Failed to atatche to shared mem";
} else { } else {
m_mem.lock(); m_mem.lock();
SHARED_MEM_TYPE *data = (SHARED_MEM_TYPE *)m_mem.data(); SHARED_MEM_TYPE *data = (SHARED_MEM_TYPE *)m_mem.data();
m_mem.unlock(); m_mem.unlock();
int elapsed = (QTime::currentTime().msecsSinceStartOfDay() - data->date) / 1000; int elapsed = (QTime::currentTime().msecsSinceStartOfDay() - data->date) / 1000;
snoreDebug(SNORE_DEBUG) << m_id << "State:" << data->free << "Time:" << elapsed << "Timeout:" << data->timeout; qCDebug(SNORE) << m_id << "State:" << data->free << "Time:" << elapsed << "Timeout:" << data->timeout;
} }
} }
} }
@ -86,7 +85,7 @@ NotifyWidget::~NotifyWidget()
void NotifyWidget::display(const Notification &notification) void NotifyWidget::display(const Notification &notification)
{ {
snoreDebug(SNORE_DEBUG) << m_id << notification.id() << m_window->isVisible(); qCDebug(SNORE) << m_id << notification.id() << m_window->isVisible();
m_notification = notification; m_notification = notification;
QColor color; QColor color;
QVariant vcolor = notification.application().constHints().privateValue(parent(), "backgroundColor"); QVariant vcolor = notification.application().constHints().privateValue(parent(), "backgroundColor");
@ -128,11 +127,11 @@ bool NotifyWidget::acquire(int timeout)
m_mem.lock(); m_mem.lock();
SHARED_MEM_TYPE *data = (SHARED_MEM_TYPE *)m_mem.data(); SHARED_MEM_TYPE *data = (SHARED_MEM_TYPE *)m_mem.data();
int elapsed = (QTime::currentTime().msecsSinceStartOfDay() - data->date) / 1000; int elapsed = (QTime::currentTime().msecsSinceStartOfDay() - data->date) / 1000;
snoreDebug(SNORE_DEBUG) << m_id << "State:" << data->free << "Time:" << elapsed << "Timeout:" << data->timeout; qCDebug(SNORE) << m_id << "State:" << data->free << "Time:" << elapsed << "Timeout:" << data->timeout;
bool isTimedOut = elapsed > data->timeout; bool isTimedOut = elapsed > data->timeout;
if (data->free || isTimedOut) { if (data->free || isTimedOut) {
if (isTimedOut) { if (isTimedOut) {
snoreDebug(SNORE_DEBUG) << "Notification Lock timed out" << elapsed; qCDebug(SNORE) << "Notification Lock timed out" << elapsed;
} }
data->free = false; data->free = false;
data->date = QTime::currentTime().msecsSinceStartOfDay(); data->date = QTime::currentTime().msecsSinceStartOfDay();
@ -155,7 +154,7 @@ bool NotifyWidget::release()
m_mem.lock(); m_mem.lock();
SHARED_MEM_TYPE *data = (SHARED_MEM_TYPE *)m_mem.data(); SHARED_MEM_TYPE *data = (SHARED_MEM_TYPE *)m_mem.data();
int elapsed = (QTime::currentTime().msecsSinceStartOfDay() - data->date) / 1000; int elapsed = (QTime::currentTime().msecsSinceStartOfDay() - data->date) / 1000;
snoreDebug(SNORE_DEBUG) << m_id << "State:" << data->free << "Time:" << elapsed << "Timeout:" << data->timeout; qCDebug(SNORE) << m_id << "State:" << data->free << "Time:" << elapsed << "Timeout:" << data->timeout;
if (!data->free) { if (!data->free) {
data->free = true; data->free = true;
m_ready = true; m_ready = true;

View File

@ -69,14 +69,14 @@ void SnoreNotifier::slotNotify(Snore::Notification notification)
if (notification.old().hints().privateValue(this, "id").isValid()) { if (notification.old().hints().privateValue(this, "id").isValid()) {
NotifyWidget *w = m_widgets[notification.old().hints().privateValue(this, "id").toInt()]; NotifyWidget *w = m_widgets[notification.old().hints().privateValue(this, "id").toInt()];
if (w->notification().isValid() && w->notification().id() == notification.old().id()) { if (w->notification().isValid() && w->notification().id() == notification.old().id()) {
snoreDebug(SNORE_DEBUG) << "replacing notification" << w->notification().id() << notification.id(); qCDebug(SNORE) << "replacing notification" << w->notification().id() << notification.id();
display(w, notification); display(w, notification);
} }
} else { } else {
for (int i = 0; i < m_queue.length(); ++i) { for (int i = 0; i < m_queue.length(); ++i) {
Notification n = m_queue.at(i); Notification n = m_queue.at(i);
if (n.id() == notification.old().id()) { if (n.id() == notification.old().id()) {
snoreDebug(SNORE_DEBUG) << "replacing qued notification" << n.id() << notification.id(); qCDebug(SNORE) << "replacing qued notification" << n.id() << notification.id();
m_queue.replace(i, notification); m_queue.replace(i, notification);
} }
} }
@ -84,7 +84,7 @@ void SnoreNotifier::slotNotify(Snore::Notification notification)
return; return;
} }
if (m_queue.isEmpty()) { if (m_queue.isEmpty()) {
foreach(NotifyWidget * w, m_widgets) { foreach (NotifyWidget *w, m_widgets) {
if (w->acquire(notification.timeout())) { if (w->acquire(notification.timeout())) {
display(w, notification); display(w, notification);
return; return;
@ -92,7 +92,7 @@ void SnoreNotifier::slotNotify(Snore::Notification notification)
} }
} }
m_queue.append(notification); m_queue.append(notification);
snoreDebug(SNORE_DEBUG) << "queing" << m_queue.size(); qCDebug(SNORE) << "queing" << m_queue.size();
if (!m_timer->isActive()) { if (!m_timer->isActive()) {
m_timer->start(); m_timer->start();
} }
@ -108,10 +108,10 @@ void SnoreNotifier::slotCloseNotification(Snore::Notification notification)
void SnoreNotifier::slotQueueTimeout() void SnoreNotifier::slotQueueTimeout()
{ {
if (m_queue.isEmpty()) { if (m_queue.isEmpty()) {
snoreDebug(SNORE_DEBUG) << "queue is empty"; qCDebug(SNORE) << "queue is empty";
m_timer->stop(); m_timer->stop();
} else { } else {
foreach(NotifyWidget * w, m_widgets) { foreach (NotifyWidget *w, m_widgets) {
if (!m_queue.isEmpty() && w->acquire(m_queue.first().timeout())) { if (!m_queue.isEmpty() && w->acquire(m_queue.first().timeout())) {
Notification notification = m_queue.takeFirst(); Notification notification = m_queue.takeFirst();
notification.hints().setPrivateValue(this, "id", w->id()); notification.hints().setPrivateValue(this, "id", w->id());

View File

@ -48,7 +48,7 @@ void SnoreToast::slotNotify(Notification notification)
if (notification.hints().value("silent").toBool() || notification.hints().value("sound").isValid()) { if (notification.hints().value("silent").toBool() || notification.hints().value("sound").isValid()) {
arguements << QLatin1String("-silent"); arguements << QLatin1String("-silent");
} }
snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements; qCDebug(SNORE) << "SnoreToast" << arguements;
connect(p, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), [this, notification](int code) { connect(p, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), [this, notification](int code) {
Notification::CloseReasons reason = Notification::NONE; Notification::CloseReasons reason = Notification::NONE;
@ -69,7 +69,7 @@ void SnoreToast::slotNotify(Notification notification)
break; break;
case -1: case -1:
//failed //failed
snoreDebug(SNORE_WARNING) << "SnoreToast failed to display " << notification; qCWarning(SNORE) << "SnoreToast failed to display " << notification;
break; break;
} }
@ -81,14 +81,14 @@ void SnoreToast::slotNotify(Notification notification)
void SnoreToast::slotRegisterApplication(const Application &application) void SnoreToast::slotRegisterApplication(const Application &application)
{ {
if (!application.constHints().contains("windows-app-id")) { if (!application.constHints().contains("windows-app-id")) {
snoreDebug(SNORE_INFO) << "No windows-app-id found in hints. Installing default shortcut with appID."; qCInfo(SNORE) << "No windows-app-id found in hints. Installing default shortcut with appID.";
QProcess *p = createProcess(Notification()); QProcess *p = createProcess(Notification());
QStringList arguements; QStringList arguements;
arguements << QLatin1String("-install") arguements << QLatin1String("-install")
<< QLatin1String("SnoreNotify\\") + qApp->applicationName() << QLatin1String("SnoreNotify\\") + qApp->applicationName()
<< QDir::toNativeSeparators(qApp->applicationFilePath()) << QDir::toNativeSeparators(qApp->applicationFilePath())
<< appId(application); << appId(application);
snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements; qCDebug(SNORE) << "SnoreToast" << arguements;
p->start(QLatin1String("SnoreToast"), arguements); p->start(QLatin1String("SnoreToast"), arguements);
} }
} }
@ -100,7 +100,7 @@ void SnoreToast::slotCloseNotification(Notification notification)
QStringList arguements; QStringList arguements;
arguements << QLatin1String("-close") arguements << QLatin1String("-close")
<< QString::number(notification.id()); << QString::number(notification.id());
snoreDebug(SNORE_DEBUG) << "SnoreToast" << arguements; qCDebug(SNORE) << "SnoreToast" << arguements;
p->start(QLatin1String("SnoreToast"), arguements); p->start(QLatin1String("SnoreToast"), arguements);
} }
@ -119,13 +119,13 @@ QProcess *SnoreToast::createProcess(Notification noti)
p->setReadChannelMode(QProcess::MergedChannels); p->setReadChannelMode(QProcess::MergedChannels);
connect(p, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), [p](int, QProcess::ExitStatus) { connect(p, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), [p](int, QProcess::ExitStatus) {
snoreDebug(SNORE_DEBUG) << p->readAll(); qCDebug(SNORE) << p->readAll();
p->deleteLater(); p->deleteLater();
}); });
connect(p, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error), [this, p, noti](QProcess::ProcessError) { connect(p, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error), [this, p, noti](QProcess::ProcessError) {
setErrorString(name() + p->errorString()); setErrorString(name() + p->errorString());
snoreDebug(SNORE_DEBUG) << p->readAll(); qCDebug(SNORE) << p->readAll();
if (noti.isValid()) { if (noti.isValid()) {
closeNotification(noti, Notification::NONE); closeNotification(noti, Notification::NONE);
} }

View File

@ -34,7 +34,7 @@ void TrayIconNotifer::slotCloseNotification(Notification n)
{ {
QSystemTrayIcon *icon = trayIcon(n.application()); QSystemTrayIcon *icon = trayIcon(n.application());
if (icon) { if (icon) {
snoreDebug(SNORE_DEBUG) << n; qCDebug(SNORE) << n;
m_currentlyDisplaying = false; m_currentlyDisplaying = false;
displayNotification(icon); displayNotification(icon);
} }

View File

@ -66,7 +66,7 @@ void PushoverFrontend::login(const QString &email, const QString &password, cons
QNetworkReply *reply = m_manager.post(request, (QLatin1String("email=") + email + QLatin1String("&password=") + password).toUtf8().constData()); QNetworkReply *reply = m_manager.post(request, (QLatin1String("email=") + email + QLatin1String("&password=") + password).toUtf8().constData());
connect(reply, &QNetworkReply::finished, [reply, deviceName, this]() { connect(reply, &QNetworkReply::finished, [reply, deviceName, this]() {
snoreDebug(SNORE_DEBUG) << reply->error(); qCDebug(SNORE) << reply->error();
QByteArray input = reply->readAll(); QByteArray input = reply->readAll();
reply->close(); reply->close();
reply->deleteLater(); reply->deleteLater();
@ -76,7 +76,7 @@ void PushoverFrontend::login(const QString &email, const QString &password, cons
if (message.value(QStringLiteral("status")).toInt() == 1) { if (message.value(QStringLiteral("status")).toInt() == 1) {
registerDevice(message.value(QStringLiteral("secret")).toString(), deviceName); registerDevice(message.value(QStringLiteral("secret")).toString(), deviceName);
} else { } else {
snoreDebug(SNORE_WARNING) << "An error occure" << input; qCWarning(SNORE) << "An error occure" << input;
emit loggedInChanged(false); emit loggedInChanged(false);
} }
}); });
@ -111,7 +111,7 @@ void PushoverFrontend::setDefaultSettings()
void PushoverFrontend::slotActionInvoked(Notification notification) void PushoverFrontend::slotActionInvoked(Notification notification)
{ {
if (notification.priority() == Notification::EMERGENCY) { if (notification.priority() == Notification::EMERGENCY) {
snoreDebug(SNORE_WARNING) << "emergeency notification" << notification; qCWarning(SNORE) << "emergeency notification" << notification;
acknowledgeNotification(notification); acknowledgeNotification(notification);
} }
} }
@ -129,49 +129,49 @@ QString PushoverFrontend::device()
void PushoverFrontend::connectToService() void PushoverFrontend::connectToService()
{ {
if (secret().isEmpty() || device().isEmpty()) { if (secret().isEmpty() || device().isEmpty()) {
snoreDebug(SNORE_WARNING) << "not logged in"; qCWarning(SNORE) << "not logged in";
return; return;
} }
snoreDebug(SNORE_DEBUG) << "Connecting ton service"; qCDebug(SNORE) << "Connecting ton service";
m_socket = new QWebSocket(QString(), QWebSocketProtocol::VersionLatest, this); m_socket = new QWebSocket(QString(), QWebSocketProtocol::VersionLatest, this);
connect(m_socket.data(), &QWebSocket::binaryMessageReceived, [&](const QByteArray & msg) { connect(m_socket.data(), &QWebSocket::binaryMessageReceived, [&](const QByteArray & msg) {
char c = msg.at(0); char c = msg.at(0);
switch (c) { switch (c) {
case '#': case '#':
snoreDebug(SNORE_DEBUG) << "still alive"; qCDebug(SNORE) << "still alive";
break; break;
case '!': case '!':
getMessages(); getMessages();
break; break;
case 'R': case 'R':
snoreDebug(SNORE_DEBUG) << "need to reconnect"; qCDebug(SNORE) << "need to reconnect";
m_socket->close(); m_socket->close();
m_socket->deleteLater(); m_socket->deleteLater();
connectToService(); connectToService();
break; break;
case 'E': case 'E':
snoreDebug(SNORE_WARNING) << "Connection Error"; qCWarning(SNORE) << "Connection Error";
emit error(QStringLiteral("Please Loggin to https://pushover.net and reanble your device.")); emit error(QStringLiteral("Please Loggin to https://pushover.net and reanble your device."));
emit loggedInChanged(false); emit loggedInChanged(false);
m_socket->close(); m_socket->close();
m_socket->deleteLater(); m_socket->deleteLater();
break; break;
default: default:
snoreDebug(SNORE_WARNING) << "unknown message received" << msg; qCWarning(SNORE) << "unknown message received" << msg;
} }
}); });
connect(m_socket.data(), &QWebSocket::disconnected, [this]() { connect(m_socket.data(), &QWebSocket::disconnected, [this]() {
snoreDebug(SNORE_WARNING) << "disconnected"; qCWarning(SNORE) << "disconnected";
//TODO: use new style connect once we depend on qt 5.4 //TODO: use new style connect once we depend on qt 5.4
QTimer::singleShot(500, this, SLOT(PushoverFrontend::connectToService())); QTimer::singleShot(500, this, SLOT(PushoverFrontend::connectToService()));
}); });
connect(m_socket.data(), static_cast<void (QWebSocket::*)(QAbstractSocket::SocketError)>(&QWebSocket::error), [&](QAbstractSocket::SocketError error) { connect(m_socket.data(), static_cast<void (QWebSocket::*)(QAbstractSocket::SocketError)>(&QWebSocket::error), [&](QAbstractSocket::SocketError error) {
snoreDebug(SNORE_WARNING) << error << m_socket->errorString(); qCWarning(SNORE) << error << m_socket->errorString();
emit loggedInChanged(false); emit loggedInChanged(false);
}); });
connect(m_socket.data(), &QWebSocket::connected, [&]() { connect(m_socket.data(), &QWebSocket::connected, [&]() {
snoreDebug(SNORE_DEBUG) << "connecting"; qCDebug(SNORE) << "connecting";
m_socket->sendBinaryMessage((QLatin1String("login:") + device() + QLatin1Char(':') + secret() + QLatin1Char('\n')).toUtf8().constData()); m_socket->sendBinaryMessage((QLatin1String("login:") + device() + QLatin1Char(':') + secret() + QLatin1Char('\n')).toUtf8().constData());
emit loggedInChanged(true); emit loggedInChanged(true);
getMessages(); getMessages();
@ -195,7 +195,7 @@ void PushoverFrontend::registerDevice(const QString &secret, const QString &devi
QNetworkReply *reply = m_manager.post(request, (QLatin1String("os=O&secret=") + secret + QLatin1String("&name=") + deviceName).toUtf8().constData()); QNetworkReply *reply = m_manager.post(request, (QLatin1String("os=O&secret=") + secret + QLatin1String("&name=") + deviceName).toUtf8().constData());
connect(reply, &QNetworkReply::finished, [reply, secret, this]() { connect(reply, &QNetworkReply::finished, [reply, secret, this]() {
snoreDebug(SNORE_DEBUG) << reply->error(); qCDebug(SNORE) << reply->error();
QByteArray input = reply->readAll(); QByteArray input = reply->readAll();
reply->close(); reply->close();
reply->deleteLater(); reply->deleteLater();
@ -205,7 +205,7 @@ void PushoverFrontend::registerDevice(const QString &secret, const QString &devi
setSettingsValue(QStringLiteral("DeviceID"), message.value(QStringLiteral("id")).toString(), LOCAL_SETTING);; setSettingsValue(QStringLiteral("DeviceID"), message.value(QStringLiteral("id")).toString(), LOCAL_SETTING);;
connectToService(); connectToService();
} else { } else {
snoreDebug(SNORE_WARNING) << "An error occure" << input; qCWarning(SNORE) << "An error occure" << input;
emit loggedInChanged(false); emit loggedInChanged(false);
emit error(message.value(QStringLiteral("error")).toString()); emit error(message.value(QStringLiteral("error")).toString());
} }
@ -221,19 +221,19 @@ void PushoverFrontend::getMessages()
QNetworkReply *reply = m_manager.get(request); QNetworkReply *reply = m_manager.get(request);
connect(reply, &QNetworkReply::finished, [reply, this]() { connect(reply, &QNetworkReply::finished, [reply, this]() {
snoreDebug(SNORE_DEBUG) << reply->error(); qCDebug(SNORE) << reply->error();
QByteArray input = reply->readAll(); QByteArray input = reply->readAll();
reply->close(); reply->close();
reply->deleteLater(); reply->deleteLater();
snoreDebug(SNORE_DEBUG) << input; qCDebug(SNORE) << input;
QJsonObject message = QJsonDocument::fromJson(input).object(); QJsonObject message = QJsonDocument::fromJson(input).object();
int latestID = -1; int latestID = -1;
if (message.value(QStringLiteral("status")).toInt() == 1) { if (message.value(QStringLiteral("status")).toInt() == 1) {
QJsonArray notifications = message.value(QStringLiteral("messages")).toArray(); QJsonArray notifications = message.value(QStringLiteral("messages")).toArray();
foreach(const QJsonValue & v, notifications) { foreach (const QJsonValue &v, notifications) {
QJsonObject notification = v.toObject(); QJsonObject notification = v.toObject();
latestID = qMax(latestID, notification.value(QStringLiteral("id")).toInt()); latestID = qMax(latestID, notification.value(QStringLiteral("id")).toInt());
@ -267,7 +267,7 @@ void PushoverFrontend::getMessages()
deleteMessages(latestID); deleteMessages(latestID);
} }
} else { } else {
snoreDebug(SNORE_WARNING) << "An error occure" << input; qCWarning(SNORE) << "An error occure" << input;
} }
}); });
@ -284,8 +284,8 @@ void PushoverFrontend::deleteMessages(int latestMessageId)
QNetworkReply *reply = m_manager.post(request, (QLatin1String("secret=") + secret() + QLatin1String("&message=") + QString::number(latestMessageId)).toUtf8().constData()); QNetworkReply *reply = m_manager.post(request, (QLatin1String("secret=") + secret() + QLatin1String("&message=") + QString::number(latestMessageId)).toUtf8().constData());
connect(reply, &QNetworkReply::finished, [reply]() { connect(reply, &QNetworkReply::finished, [reply]() {
snoreDebug(SNORE_DEBUG) << reply->error(); qCDebug(SNORE) << reply->error();
snoreDebug(SNORE_DEBUG) << reply->readAll(); qCDebug(SNORE) << reply->readAll();
reply->close(); reply->close();
reply->deleteLater(); reply->deleteLater();
}); });
@ -296,18 +296,18 @@ void PushoverFrontend::acknowledgeNotification(Notification notification)
if (notification.constHints().value("acked").toInt() == 1) { if (notification.constHints().value("acked").toInt() == 1) {
return; return;
} }
snoreDebug(SNORE_DEBUG) << notification.constHints().value("acked").toInt(); qCDebug(SNORE) << notification.constHints().value("acked").toInt();
QString receipt = notification.constHints().value("receipt").toString(); QString receipt = notification.constHints().value("receipt").toString();
QNetworkRequest request(QUrl::fromEncoded((QLatin1String("https://api.pushover.net/1/receipts/") + QNetworkRequest request(QUrl::fromEncoded((QLatin1String("https://api.pushover.net/1/receipts/") +
receipt + QLatin1String("/acknowledge.json")).toUtf8().constData())); receipt + QLatin1String("/acknowledge.json")).toUtf8().constData()));
snoreDebug(SNORE_WARNING) << request.url(); qCWarning(SNORE) << request.url();
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QLatin1String("application/x-www-form-urlencoded"))); request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QLatin1String("application/x-www-form-urlencoded")));
QNetworkReply *reply = m_manager.post(request, (QLatin1String("secret=") + secret()).toUtf8().constData()); QNetworkReply *reply = m_manager.post(request, (QLatin1String("secret=") + secret()).toUtf8().constData());
connect(reply, &QNetworkReply::finished, [reply]() { connect(reply, &QNetworkReply::finished, [reply]() {
snoreDebug(SNORE_DEBUG) << reply->error(); qCDebug(SNORE) << reply->error();
snoreDebug(SNORE_DEBUG) << reply->readAll(); qCDebug(SNORE) << reply->readAll();
//TODO:parse reply //TODO:parse reply
reply->close(); reply->close();
reply->deleteLater(); reply->deleteLater();

View File

@ -50,7 +50,7 @@ Parser::Parser(SnarlNetworkFrontend *snarl):
void Parser::parse(Notification &sNotification, const QString &msg, QTcpSocket *client) void Parser::parse(Notification &sNotification, const QString &msg, QTcpSocket *client)
{ {
snoreDebug(SNORE_DEBUG) << msg; qCDebug(SNORE) << msg;
QStringList splitted(msg.split(QStringLiteral("#?"))); QStringList splitted(msg.split(QStringLiteral("#?")));
snpTypes action(ERROR); snpTypes action(ERROR);
@ -64,7 +64,7 @@ void Parser::parse(Notification &sNotification, const QString &msg, QTcpSocket *
QByteArray key; QByteArray key;
QString value; QString value;
foreach(const QString & s, splitted) { foreach (const QString &s, splitted) {
key = s.mid(0, s.indexOf(QLatin1String("="))).toLower().toLatin1(); key = s.mid(0, s.indexOf(QLatin1String("="))).toLower().toLatin1();
value = s.mid(s.indexOf(QLatin1String("=")) + 1); value = s.mid(s.indexOf(QLatin1String("=")) + 1);
switch (getSnpType.value(key)) { switch (getSnpType.value(key)) {
@ -119,7 +119,7 @@ void Parser::parse(Notification &sNotification, const QString &msg, QTcpSocket *
} }
case ADD_CLASS: case ADD_CLASS:
if (alertName.isEmpty()) { if (alertName.isEmpty()) {
snoreDebug(SNORE_DEBUG) << "Error registering alert with empty name"; qCDebug(SNORE) << "Error registering alert with empty name";
break; break;
} }
alert = Alert(alertName, icon); alert = Alert(alertName, icon);
@ -129,7 +129,7 @@ void Parser::parse(Notification &sNotification, const QString &msg, QTcpSocket *
if (!snarl->m_applications.contains(client)) { if (!snarl->m_applications.contains(client)) {
snarl->m_applications[client] = Application(appName, icon); snarl->m_applications[client] = Application(appName, icon);
} else { } else {
snoreDebug(SNORE_DEBUG) << appName << "already registred"; qCDebug(SNORE) << appName << "already registred";
} }
break; break;
case UNREGISTER: case UNREGISTER:

View File

@ -52,7 +52,7 @@ SnarlNetworkFrontend::~SnarlNetworkFrontend()
void SnarlNetworkFrontend::slotActionInvoked(Snore::Notification notification) void SnarlNetworkFrontend::slotActionInvoked(Snore::Notification notification)
{ {
if (notification.isActiveIn(this)) { if (notification.isActiveIn(this)) {
snoreDebug(SNORE_DEBUG) << notification.closeReason(); qCDebug(SNORE) << notification.closeReason();
callback(notification, QStringLiteral("SNP/1.1/304/Notification acknowledged/")); callback(notification, QStringLiteral("SNP/1.1/304/Notification acknowledged/"));
} }
} }
@ -72,7 +72,7 @@ void SnarlNetworkFrontend::slotNotificationClosed(Snore::Notification notificati
callback(notification, QStringLiteral("SNP/1.1/302/Notification cancelled/")); callback(notification, QStringLiteral("SNP/1.1/302/Notification cancelled/"));
break; break;
default: default:
snoreDebug(SNORE_WARNING) << "Unhandled close reason" << notification.closeReason(); qCWarning(SNORE) << "Unhandled close reason" << notification.closeReason();
} }
} }
} }
@ -90,7 +90,7 @@ void SnarlNetworkFrontend::handleMessages()
QTcpSocket *client = qobject_cast<QTcpSocket *>(sender()); QTcpSocket *client = qobject_cast<QTcpSocket *>(sender());
QStringList messages(QString::fromLatin1(client->readAll()).trimmed().split(QStringLiteral("\r\n"))); QStringList messages(QString::fromLatin1(client->readAll()).trimmed().split(QStringLiteral("\r\n")));
foreach(const QString & s, messages) { foreach (const QString &s, messages) {
if (s.isEmpty()) { if (s.isEmpty()) {
continue; continue;
} }

View File

@ -19,7 +19,6 @@
#ifndef SNARLNETWORK_H #ifndef SNARLNETWORK_H
#define SNARLNETWORK_H #define SNARLNETWORK_H
#include "libsnore/plugins/snorefrontend.h" #include "libsnore/plugins/snorefrontend.h"
#include "libsnore/log.h"
#include "parser.h" #include "parser.h"
#include <QTcpSocket> #include <QTcpSocket>
@ -55,7 +54,7 @@ private:
inline void write(QTcpSocket *dest, const QString &msg) inline void write(QTcpSocket *dest, const QString &msg)
{ {
snoreDebug(SNORE_DEBUG) << msg; qCDebug(SNORE) << msg;
dest->write(msg.toLatin1()); dest->write(msg.toLatin1());
} }

View File

@ -18,7 +18,6 @@
#include "nma.h" #include "nma.h"
#include "nmasettings.h" #include "nmasettings.h"
#include "libsnore/log.h"
#include "libsnore/utils.h" #include "libsnore/utils.h"
#include <QNetworkReply> #include <QNetworkReply>
@ -52,8 +51,8 @@ void NotifyMyAndroid::slotNotify(Notification notification)
QNetworkReply *reply = m_manager.post(request, data.toUtf8().constData()); QNetworkReply *reply = m_manager.post(request, data.toUtf8().constData());
connect(reply, &QNetworkReply::finished, [reply]() { connect(reply, &QNetworkReply::finished, [reply]() {
snoreDebug(SNORE_DEBUG) << reply->error(); qCDebug(SNORE) << reply->error();
snoreDebug(SNORE_DEBUG) << reply->readAll(); qCDebug(SNORE) << reply->readAll();
reply->close(); reply->close();
reply->deleteLater(); reply->deleteLater();
}); });

View File

@ -18,7 +18,6 @@
#include "pushover.h" #include "pushover.h"
#include "pushoversettings.h" #include "pushoversettings.h"
#include "libsnore/log.h"
#include "libsnore/utils.h" #include "libsnore/utils.h"
#include "libsnore/notification/notification_p.h" #include "libsnore/notification/notification_p.h"
@ -61,8 +60,8 @@ void Pushover::slotNotify(Notification notification)
QHttpPart text; QHttpPart text;
text.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"message\""))); text.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"message\"")));
snoreDebug(SNORE_DEBUG) << "Use Markup" << notification.constHints().value("use-markup").toBool(); qCDebug(SNORE) << "Use Markup" << notification.constHints().value("use-markup").toBool();
snoreDebug(SNORE_DEBUG) << "Message" << textString; qCDebug(SNORE) << "Message" << textString;
text.setBody(textString.toUtf8().constData()); text.setBody(textString.toUtf8().constData());
mp->append(text); mp->append(text);
@ -113,8 +112,8 @@ void Pushover::slotNotify(Notification notification)
mp->setParent(reply); mp->setParent(reply);
connect(reply, &QNetworkReply::finished, [reply]() { connect(reply, &QNetworkReply::finished, [reply]() {
snoreDebug(SNORE_DEBUG) << reply->error(); qCDebug(SNORE) << reply->error();
snoreDebug(SNORE_DEBUG) << reply->readAll(); qCDebug(SNORE) << reply->readAll();
reply->close(); reply->close();
reply->deleteLater(); reply->deleteLater();
}); });

View File

@ -18,8 +18,6 @@
#include "sound.h" #include "sound.h"
#include "soundsettings.h" #include "soundsettings.h"
#include "libsnore/log.h"
#include <QtMultimedia/QMediaPlayer> #include <QtMultimedia/QMediaPlayer>
#include <QTimer> #include <QTimer>
@ -29,10 +27,10 @@ Sound::Sound():
m_player(new QMediaPlayer(this)) m_player(new QMediaPlayer(this))
{ {
// connect(m_player,QMediaPlayer::positionChanged,[](qint64 pos){ // connect(m_player,QMediaPlayer::positionChanged,[](qint64 pos){
// snoreDebug(SNORE_DEBUG) << "Player: " << pos; // qCDebug(SNORE) << "Player: " << pos;
// }); // });
connect(m_player, &QMediaPlayer::stateChanged, [](QMediaPlayer::State state) { connect(m_player, &QMediaPlayer::stateChanged, [](QMediaPlayer::State state) {
snoreDebug(SNORE_DEBUG) << "Player: " << state; qCDebug(SNORE) << "Player: " << state;
}); });
} }
@ -58,10 +56,10 @@ void Sound::slotNotificationDisplayed(Snore::Notification notification)
if (sound.isEmpty()) { if (sound.isEmpty()) {
sound = settingsValue(QLatin1String("Sound")).toString(); sound = settingsValue(QLatin1String("Sound")).toString();
} }
snoreDebug(SNORE_DEBUG) << "SoundFile:" << sound; qCDebug(SNORE) << "SoundFile:" << sound;
if (!sound.isEmpty()) { if (!sound.isEmpty()) {
m_player->setMedia(QUrl::fromLocalFile(sound)); m_player->setMedia(QUrl::fromLocalFile(sound));
snoreDebug(SNORE_DEBUG) << "SoundFile:" << m_player->media().canonicalUrl(); qCDebug(SNORE) << "SoundFile:" << m_player->media().canonicalUrl();
m_player->play(); m_player->play();
QTimer *timeout = new QTimer(this); QTimer *timeout = new QTimer(this);
timeout->setSingleShot(true); timeout->setSingleShot(true);

View File

@ -18,7 +18,6 @@
#include "toasty.h" #include "toasty.h"
#include "toastysettings.h" #include "toastysettings.h"
#include "libsnore/log.h"
#include "libsnore/utils.h" #include "libsnore/utils.h"
#include <QNetworkReply> #include <QNetworkReply>
@ -66,8 +65,8 @@ void Toasty::slotNotify(Notification notification)
file->setParent(reply); file->setParent(reply);
connect(reply, &QNetworkReply::finished, [reply]() { connect(reply, &QNetworkReply::finished, [reply]() {
snoreDebug(SNORE_DEBUG) << reply->error(); qCDebug(SNORE) << reply->error();
snoreDebug(SNORE_DEBUG) << reply->readAll(); qCDebug(SNORE) << reply->readAll();
reply->close(); reply->close();
reply->deleteLater(); reply->deleteLater();
}); });

View File

@ -46,7 +46,7 @@ bool setSetting(const QString &appName, SettingsType type, const QString &_key,
void listApps() void listApps()
{ {
foreach(const QString & app, SettingsWindow::knownApps()) { foreach (const QString &app, SettingsWindow::knownApps()) {
cout << qPrintable(app) << endl; cout << qPrintable(app) << endl;
} }
} }
@ -63,8 +63,8 @@ void listSettings(SettingsType type, const QString &application)
prefix = QString(); prefix = QString();
} }
cout << qPrintable(application) << endl; cout << qPrintable(application) << endl;
foreach(const QString & key, SettingsWindow::allSettingsKeysWithPrefix( foreach (const QString &key, SettingsWindow::allSettingsKeysWithPrefix(
Utils::normalizeSettingsKey(QLatin1String(""), type, prefix), settings, getAllKeys)) { Utils::normalizeSettingsKey(QLatin1String(""), type, prefix), settings, getAllKeys)) {
cout << " " << qPrintable(key) << ": " << qPrintable(settings.value(Utils::normalizeSettingsKey(key, type, prefix)).toString()) << endl; cout << " " << qPrintable(key) << ": " << qPrintable(settings.value(Utils::normalizeSettingsKey(key, type, prefix)).toString()) << endl;
} }
} }

View File

@ -98,6 +98,6 @@ void SettingsWindow::on_buttonBox_clicked(QAbstractButton *button)
qApp->quit(); qApp->quit();
break; break;
default: default:
snoreDebug(SNORE_WARNING) << "unhandled role" << button->text() << ui->buttonBox->buttonRole(button); qCWarning(SNORE) << "unhandled role" << button->text() << ui->buttonBox->buttonRole(button);
} }
} }

View File

@ -46,7 +46,7 @@ public:
QStringList groups = prefix.split(QLatin1Char('/')); QStringList groups = prefix.split(QLatin1Char('/'));
QStringList out; QStringList out;
foreach(const QString & group, groups) { foreach (const QString &group, groups) {
settings.beginGroup(group); settings.beginGroup(group);
} }
out = fun(settings); out = fun(settings);

View File

@ -18,7 +18,6 @@
#include <libsnore/snore.h> #include <libsnore/snore.h>
#include <libsnore/notification/notification.h> #include <libsnore/notification/notification.h>
#include <libsnore/log.h>
#include <libsnore/version.h> #include <libsnore/version.h>
#include <libsnore/utils.h> #include <libsnore/utils.h>
@ -39,7 +38,7 @@ using namespace std;
void bringToFront(QString pid) void bringToFront(QString pid)
{ {
snoreDebug(SNORE_DEBUG) << pid; qCDebug(SNORE) << pid;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
auto findWindowForPid = [](ulong pid) { auto findWindowForPid = [](ulong pid) {
// based on http://stackoverflow.com/a/21767578 // based on http://stackoverflow.com/a/21767578
@ -112,7 +111,7 @@ int main(int argc, char *argv[])
parser.addOption(_bringWindowToFront); parser.addOption(_bringWindowToFront);
parser.process(app); parser.process(app);
snoreDebug(SNORE_DEBUG) << app.arguments(); qCDebug(SNORE) << app.arguments();
if (parser.isSet(title) && parser.isSet(message)) { if (parser.isSet(title) && parser.isSet(message)) {
SnoreCore &core = SnoreCore::instance(); SnoreCore &core = SnoreCore::instance();