mboximportkernel.cpp 3.37 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1
/*
Laurent Montel's avatar
Laurent Montel committed
2
   Copyright (C) 2013-2016 Montel Laurent <montel@kde.org>
Laurent Montel's avatar
Laurent Montel committed
3

Laurent Montel's avatar
Laurent Montel committed
4 5 6 7
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
Laurent Montel's avatar
Laurent Montel committed
8

Laurent Montel's avatar
Laurent Montel committed
9 10 11 12
   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.
Laurent Montel's avatar
Laurent Montel committed
13

Laurent Montel's avatar
Laurent Montel committed
14 15 16 17
   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
Laurent Montel's avatar
Laurent Montel committed
18 19 20 21
*/

#include "mboximportkernel.h"

Laurent Montel's avatar
Laurent Montel committed
22
#include <KIdentityManagement/kidentitymanagement/identitymanager.h>
Laurent Montel's avatar
Laurent Montel committed
23
#include <MailCommon/FolderCollectionMonitor>
Laurent Montel's avatar
Laurent Montel committed
24 25 26 27
#include <AkonadiCore/session.h>
#include <entitytreemodel.h>
#include <entitymimetypefiltermodel.h>
#include <changerecorder.h>
28
#include <KSharedConfig>
Laurent Montel's avatar
Laurent Montel committed
29

Laurent Montel's avatar
Laurent Montel committed
30 31
MBoxImporterKernel::MBoxImporterKernel(QObject *parent)
    : QObject(parent)
Laurent Montel's avatar
Laurent Montel committed
32
{
Laurent Montel's avatar
Laurent Montel committed
33
    mIdentityManager = new KIdentityManagement::IdentityManager(false, this);
Laurent Montel's avatar
Laurent Montel committed
34 35 36 37
    Akonadi::Session *session = new Akonadi::Session("MBox importer Kernel ETM", this);
    mFolderCollectionMonitor = new MailCommon::FolderCollectionMonitor(session, this);

    mEntityTreeModel = new Akonadi::EntityTreeModel(folderCollectionMonitor(), this);
38
    mEntityTreeModel->setListFilter(Akonadi::CollectionFetchScope::Enabled);
Laurent Montel's avatar
Laurent Montel committed
39 40 41 42 43 44 45 46
    mEntityTreeModel->setItemPopulationStrategy(Akonadi::EntityTreeModel::LazyPopulation);

    mCollectionModel = new Akonadi::EntityMimeTypeFilterModel(this);
    mCollectionModel->setSourceModel(mEntityTreeModel);
    mCollectionModel->addMimeTypeInclusionFilter(Akonadi::Collection::mimeType());
    mCollectionModel->setHeaderGroup(Akonadi::EntityTreeModel::CollectionTreeHeaders);
    mCollectionModel->setDynamicSortFilter(true);
    mCollectionModel->setSortCaseSensitivity(Qt::CaseInsensitive);
Laurent Montel's avatar
Laurent Montel committed
47 48
}

Laurent Montel's avatar
Laurent Montel committed
49
KIdentityManagement::IdentityManager *MBoxImporterKernel::identityManager()
Laurent Montel's avatar
Laurent Montel committed
50 51 52 53 54 55
{
    return mIdentityManager;
}

MessageComposer::MessageSender *MBoxImporterKernel::msgSender()
{
Laurent Montel's avatar
Laurent Montel committed
56
    return 0;
Laurent Montel's avatar
Laurent Montel committed
57 58 59 60 61 62 63 64 65
}

Akonadi::EntityMimeTypeFilterModel *MBoxImporterKernel::collectionModel() const
{
    return mCollectionModel;
}

KSharedConfig::Ptr MBoxImporterKernel::config()
{
66
    return KSharedConfig::openConfig();
Laurent Montel's avatar
Laurent Montel committed
67 68 69 70
}

void MBoxImporterKernel::syncConfig()
{
Laurent Montel's avatar
Laurent Montel committed
71
    Q_ASSERT(false);
Laurent Montel's avatar
Laurent Montel committed
72 73
}

Laurent Montel's avatar
Laurent Montel committed
74
MailCommon::JobScheduler *MBoxImporterKernel::jobScheduler() const
Laurent Montel's avatar
Laurent Montel committed
75
{
Laurent Montel's avatar
Laurent Montel committed
76
    Q_ASSERT(false);
Laurent Montel's avatar
Laurent Montel committed
77 78 79 80 81 82 83 84 85 86
    return 0;
}

Akonadi::ChangeRecorder *MBoxImporterKernel::folderCollectionMonitor() const
{
    return mFolderCollectionMonitor->monitor();
}

void MBoxImporterKernel::updateSystemTray()
{
Laurent Montel's avatar
Laurent Montel committed
87
    Q_ASSERT(false);
Laurent Montel's avatar
Laurent Montel committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101
}

bool MBoxImporterKernel::showPopupAfterDnD()
{
    return false;
}

qreal MBoxImporterKernel::closeToQuotaThreshold()
{
    return 80;
}

QStringList MBoxImporterKernel::customTemplates()
{
Laurent Montel's avatar
Laurent Montel committed
102
    Q_ASSERT(false);
Laurent Montel's avatar
Laurent Montel committed
103 104 105 106 107
    return QStringList();
}

bool MBoxImporterKernel::excludeImportantMailFromExpiry()
{
Laurent Montel's avatar
Laurent Montel committed
108
    Q_ASSERT(false);
Laurent Montel's avatar
Laurent Montel committed
109 110 111
    return true;
}

112
Akonadi::Collection::Id MBoxImporterKernel::lastSelectedFolder()
Laurent Montel's avatar
Laurent Montel committed
113
{
Laurent Montel's avatar
Laurent Montel committed
114
    Q_ASSERT(false);
115
    return Akonadi::Collection::Id();
Laurent Montel's avatar
Laurent Montel committed
116 117
}

Laurent Montel's avatar
Laurent Montel committed
118
void MBoxImporterKernel::setLastSelectedFolder(Akonadi::Collection::Id col)
Laurent Montel's avatar
Laurent Montel committed
119 120 121
{
    Q_UNUSED(col);
}