Commit 3afd8162 authored by Laurent Montel's avatar Laurent Montel 😁

Finally util.* file is not useful. Not necessary to make it static

parent 3a609ac1
...@@ -16,7 +16,6 @@ set(newmailnotifieragent_SRCS ...@@ -16,7 +16,6 @@ set(newmailnotifieragent_SRCS
specialnotifierjob.cpp specialnotifierjob.cpp
newmailnotifierselectcollectionwidget.cpp newmailnotifierselectcollectionwidget.cpp
newmailnotifiershowmessagejob.cpp newmailnotifiershowmessagejob.cpp
util.cpp
) )
kde4_add_kcfg_files(newmailnotifieragent_SRCS kde4_add_kcfg_files(newmailnotifieragent_SRCS
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "newmailnotifieragent.h" #include "newmailnotifieragent.h"
#include "util.h"
#include "newmailnotifierattribute.h" #include "newmailnotifierattribute.h"
#include "specialnotifierjob.h" #include "specialnotifierjob.h"
#include "newmailnotifieradaptor.h" #include "newmailnotifieradaptor.h"
...@@ -494,7 +492,12 @@ void NewMailNotifierAgent::slotShowNotifications() ...@@ -494,7 +492,12 @@ void NewMailNotifierAgent::slotShowNotifications()
void NewMailNotifierAgent::slotDisplayNotification(const QPixmap &pixmap, const QString &message) 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() ) { if ( NewMailNotifierAgentSettings::beepOnNewMails() ) {
KNotification::beep(); KNotification::beep();
...@@ -530,7 +533,7 @@ void NewMailNotifierAgent::slotInstanceStatusChanged(const Akonadi::AgentInstanc ...@@ -530,7 +533,7 @@ void NewMailNotifierAgent::slotInstanceStatusChanged(const Akonadi::AgentInstanc
} }
case Akonadi::AgentInstance::Running: case Akonadi::AgentInstance::Running:
{ {
if (!Util::excludeAgentType(instance)) { if (!excludeAgentType(instance)) {
if (!mInstanceNameInProgress.contains(identifier)) { if (!mInstanceNameInProgress.contains(identifier)) {
mInstanceNameInProgress.append(identifier); mInstanceNameInProgress.append(identifier);
} }
...@@ -543,6 +546,21 @@ void NewMailNotifierAgent::slotInstanceStatusChanged(const Akonadi::AgentInstanc ...@@ -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) void NewMailNotifierAgent::slotInstanceRemoved(const Akonadi::AgentInstance &instance)
{ {
if (!isActive()) if (!isActive())
......
...@@ -98,6 +98,7 @@ private slots: ...@@ -98,6 +98,7 @@ private slots:
void slotInstanceNameChanged(const Akonadi::AgentInstance &instance); void slotInstanceNameChanged(const Akonadi::AgentInstance &instance);
private: private:
bool excludeAgentType(const Akonadi::AgentInstance &instance);
bool ignoreStatusMail(const Akonadi::Item &item); bool ignoreStatusMail(const Akonadi::Item &item);
bool isActive() const; bool isActive() const;
void clearAll(); void clearAll();
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "newmailnotifiershowmessagejob.h" #include "newmailnotifiershowmessagejob.h"
#include "specialnotifierjob.h" #include "specialnotifierjob.h"
#include "util.h"
#include "newmailnotifieragentsettings.h" #include "newmailnotifieragentsettings.h"
#include <Akonadi/Contact/ContactSearchJob> #include <Akonadi/Contact/ContactSearchJob>
......
/*
Copyright (c) 2013-2015 Montel Laurent <montel@kde.org>
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 <KNotification>
#include <KLocalizedString>
#include <KGlobal>
#include <Akonadi/AgentInstance>
#include <Akonadi/AgentType>
#include <KMime/Message>
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;
}
/*
Copyright (c) 2013-2015 Montel Laurent <montel@kde.org>
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 <QPixmap>
#include <QString>
namespace Akonadi {
class AgentInstance;
}
namespace Util {
void showNotification(const QPixmap &pixmap, const QString &message);
bool excludeAgentType(const Akonadi::AgentInstance &instance);
}
#endif // UTIL_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment