File indexing completed on 2025-01-05 04:53:57

0001 /*
0002    SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "kmailplugininterface.h"
0008 #include "kmail_debug.h"
0009 #include "kmmainwidget.h"
0010 
0011 KMailPluginInterface::KMailPluginInterface(QObject *parent)
0012     : PimCommon::PluginInterface(parent)
0013 {
0014     setPluginName(QStringLiteral("kmail"));
0015     setPluginDirectory(QStringLiteral("pim6/kmail/mainview"));
0016 }
0017 
0018 KMailPluginInterface::~KMailPluginInterface() = default;
0019 
0020 KMailPluginInterface *KMailPluginInterface::self()
0021 {
0022     static KMailPluginInterface s_self;
0023     return &s_self;
0024 }
0025 
0026 void KMailPluginInterface::setMainWidget(KMMainWidget *mainwindow)
0027 {
0028     mMainWindow = mainwindow;
0029 }
0030 
0031 bool KMailPluginInterface::initializeInterfaceRequires(PimCommon::AbstractGenericPluginInterface *abstractInterface)
0032 {
0033     if (!mMainWindow) {
0034         qCCritical(KMAIL_LOG) << "mainwindows not defined";
0035         return false;
0036     }
0037     auto interface = static_cast<PimCommon::GenericPluginInterface *>(abstractInterface);
0038     const PimCommon::GenericPluginInterface::RequireTypes requiresFeatures = interface->requiresFeatures();
0039     if (requiresFeatures & PimCommon::GenericPluginInterface::CurrentItems) {
0040         interface->setItems(mMainWindow->currentSelection());
0041     }
0042     if (requiresFeatures & PimCommon::GenericPluginInterface::Items) {
0043         qCDebug(KMAIL_LOG) << "PimCommon::GenericPluginInterface::Items not implemented";
0044     }
0045     if (requiresFeatures & PimCommon::GenericPluginInterface::CurrentCollection) {
0046         if (mMainWindow->currentCollection().isValid()) {
0047             interface->setCurrentCollection(mMainWindow->currentCollection());
0048         } else {
0049             qCDebug(KMAIL_LOG) << "Current Collection not defined";
0050         }
0051     }
0052     if (requiresFeatures & PimCommon::GenericPluginInterface::Collections) {
0053         qCDebug(KMAIL_LOG) << "PimCommon::GenericPluginInterface::Collection not implemented";
0054     }
0055     return true;
0056 }
0057 
0058 #include "moc_kmailplugininterface.cpp"