util.cpp 1.72 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1
/*
Laurent Montel's avatar
Laurent Montel committed
2
  Copyright (c) 2013-2015 Montel Laurent <montel@kde.org>
Laurent Montel's avatar
Laurent Montel committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

  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>
Laurent Montel's avatar
Laurent Montel committed
21
#include <KLocalizedString>
Laurent Montel's avatar
Laurent Montel committed
22 23
#include <KGlobal>

24 25 26 27
#include <Akonadi/AgentInstance>
#include <Akonadi/AgentType>
#include <KMime/Message>

28

Laurent Montel's avatar
Laurent Montel committed
29 30 31 32 33 34 35 36 37
void Util::showNotification(const QPixmap &pixmap, const QString &message)
{
    KNotification::event( QLatin1String("new-email"),
                          message,
                          pixmap,
                          0,
                          KNotification::CloseOnTimeout,
                          KGlobal::mainComponent());
}
Laurent Montel's avatar
Laurent Montel committed
38

39 40 41 42 43 44 45 46
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;
Laurent Montel's avatar
Laurent Montel committed
47 48
        } else {
            return true;
49 50
        }
    }
Laurent Montel's avatar
Laurent Montel committed
51
    return true;
52
}