From 3afd81622d5b1b1e596e927a7aaa741bb6836b57 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Wed, 7 Jan 2015 13:28:41 +0100 Subject: [PATCH] Finally util.* file is not useful. Not necessary to make it static --- agents/newmailnotifier/CMakeLists.txt | 1 - .../newmailnotifier/newmailnotifieragent.cpp | 26 ++++++++-- agents/newmailnotifier/newmailnotifieragent.h | 1 + agents/newmailnotifier/specialnotifierjob.cpp | 1 - agents/newmailnotifier/util.cpp | 52 ------------------- agents/newmailnotifier/util.h | 33 ------------ 6 files changed, 23 insertions(+), 91 deletions(-) delete mode 100644 agents/newmailnotifier/util.cpp delete mode 100644 agents/newmailnotifier/util.h diff --git a/agents/newmailnotifier/CMakeLists.txt b/agents/newmailnotifier/CMakeLists.txt index 714363f92..3c114ad7a 100644 --- a/agents/newmailnotifier/CMakeLists.txt +++ b/agents/newmailnotifier/CMakeLists.txt @@ -16,7 +16,6 @@ set(newmailnotifieragent_SRCS specialnotifierjob.cpp newmailnotifierselectcollectionwidget.cpp newmailnotifiershowmessagejob.cpp - util.cpp ) kde4_add_kcfg_files(newmailnotifieragent_SRCS diff --git a/agents/newmailnotifier/newmailnotifieragent.cpp b/agents/newmailnotifier/newmailnotifieragent.cpp index 48a03bc96..4011f41f9 100644 --- a/agents/newmailnotifier/newmailnotifieragent.cpp +++ b/agents/newmailnotifier/newmailnotifieragent.cpp @@ -21,8 +21,6 @@ #include "newmailnotifieragent.h" -#include "util.h" - #include "newmailnotifierattribute.h" #include "specialnotifierjob.h" #include "newmailnotifieradaptor.h" @@ -494,7 +492,12 @@ void NewMailNotifierAgent::slotShowNotifications() void NewMailNotifierAgent::slotDisplayNotification(const QPixmap &pixmap, const QString &message) { - Util::showNotification(pixmap, message); + KNotification::event( QLatin1String("new-email"), + message, + pixmap, + 0, + KNotification::CloseOnTimeout, + KGlobal::mainComponent()); if ( NewMailNotifierAgentSettings::beepOnNewMails() ) { KNotification::beep(); @@ -530,7 +533,7 @@ void NewMailNotifierAgent::slotInstanceStatusChanged(const Akonadi::AgentInstanc } case Akonadi::AgentInstance::Running: { - if (!Util::excludeAgentType(instance)) { + if (!excludeAgentType(instance)) { if (!mInstanceNameInProgress.contains(identifier)) { mInstanceNameInProgress.append(identifier); } @@ -543,6 +546,21 @@ void NewMailNotifierAgent::slotInstanceStatusChanged(const Akonadi::AgentInstanc } } +bool NewMailNotifierAgent::excludeAgentType(const Akonadi::AgentInstance &instance) +{ + if ( instance.type().mimeTypes().contains( KMime::Message::mimeType() ) ) { + const QStringList capabilities( instance.type().capabilities() ); + if ( capabilities.contains( QLatin1String("Resource") ) && + !capabilities.contains( QLatin1String("Virtual") ) && + !capabilities.contains( QLatin1String("MailTransport") ) ) { + return false; + } else { + return true; + } + } + return true; +} + void NewMailNotifierAgent::slotInstanceRemoved(const Akonadi::AgentInstance &instance) { if (!isActive()) diff --git a/agents/newmailnotifier/newmailnotifieragent.h b/agents/newmailnotifier/newmailnotifieragent.h index 17383214e..1748bb476 100644 --- a/agents/newmailnotifier/newmailnotifieragent.h +++ b/agents/newmailnotifier/newmailnotifieragent.h @@ -98,6 +98,7 @@ private slots: void slotInstanceNameChanged(const Akonadi::AgentInstance &instance); private: + bool excludeAgentType(const Akonadi::AgentInstance &instance); bool ignoreStatusMail(const Akonadi::Item &item); bool isActive() const; void clearAll(); diff --git a/agents/newmailnotifier/specialnotifierjob.cpp b/agents/newmailnotifier/specialnotifierjob.cpp index 88f5c27c1..a5f9a0521 100644 --- a/agents/newmailnotifier/specialnotifierjob.cpp +++ b/agents/newmailnotifier/specialnotifierjob.cpp @@ -17,7 +17,6 @@ #include "newmailnotifiershowmessagejob.h" #include "specialnotifierjob.h" -#include "util.h" #include "newmailnotifieragentsettings.h" #include diff --git a/agents/newmailnotifier/util.cpp b/agents/newmailnotifier/util.cpp deleted file mode 100644 index e5852b201..000000000 --- a/agents/newmailnotifier/util.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright (c) 2013-2015 Montel Laurent - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License, version 2, as - published by the Free Software Foundation. - - This program 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "util.h" - -#include -#include -#include - -#include -#include -#include - - -void Util::showNotification(const QPixmap &pixmap, const QString &message) -{ - KNotification::event( QLatin1String("new-email"), - message, - pixmap, - 0, - KNotification::CloseOnTimeout, - KGlobal::mainComponent()); -} - -bool Util::excludeAgentType(const Akonadi::AgentInstance &instance) -{ - if ( instance.type().mimeTypes().contains( KMime::Message::mimeType() ) ) { - const QStringList capabilities( instance.type().capabilities() ); - if ( capabilities.contains( QLatin1String("Resource") ) && - !capabilities.contains( QLatin1String("Virtual") ) && - !capabilities.contains( QLatin1String("MailTransport") ) ) { - return false; - } else { - return true; - } - } - return true; -} diff --git a/agents/newmailnotifier/util.h b/agents/newmailnotifier/util.h deleted file mode 100644 index 8367194d8..000000000 --- a/agents/newmailnotifier/util.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (c) 2013-2015 Montel Laurent - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License, version 2, as - published by the Free Software Foundation. - - This program 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef UTIL_H -#define UTIL_H - -#include -#include - -namespace Akonadi { -class AgentInstance; -} - -namespace Util { -void showNotification(const QPixmap &pixmap, const QString &message); -bool excludeAgentType(const Akonadi::AgentInstance &instance); -} - -#endif // UTIL_H -- GitLab