File indexing completed on 2025-01-05 04:53:36
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "mailagentdbuswidget.h" 0008 0009 #include <Akonadi/Monitor> 0010 #include <Akonadi/ServerManager> 0011 #include <QDebug> 0012 #include <QPushButton> 0013 #include <QVBoxLayout> 0014 0015 MailAgentDbusWidget::MailAgentDbusWidget(QWidget *parent) 0016 : QWidget{parent} 0017 { 0018 const auto service = Akonadi::ServerManager::agentServiceName(Akonadi::ServerManager::Agent, QStringLiteral("akonadi_mailfilter_agent")); 0019 mMailFilterAgentInterface = 0020 new org::freedesktop::Akonadi::MailFilterAgent(service, QStringLiteral("/MailFilterAgent"), QDBusConnection::sessionBus(), this); 0021 0022 auto mainLayout = new QVBoxLayout(this); 0023 0024 auto openfilterLogViewer = new QPushButton(QStringLiteral("Open Filter Log Viewer"), this); 0025 connect(openfilterLogViewer, &QPushButton::clicked, this, [this]() { 0026 qDebug() << " open filter log viewer"; 0027 mMailFilterAgentInterface->showFilterLogDialog(0); 0028 }); 0029 mainLayout->addWidget(openfilterLogViewer); 0030 0031 auto printCollectionMonitored = new QPushButton(QStringLiteral("Print Collection Monitored"), this); 0032 connect(printCollectionMonitored, &QPushButton::clicked, this, [this]() { 0033 qDebug() << " print collection monitored"; 0034 const QString str = mMailFilterAgentInterface->printCollectionMonitored(); 0035 qDebug() << " result " << str; 0036 }); 0037 mainLayout->addWidget(printCollectionMonitored); 0038 auto testFilterItems = new QPushButton(QStringLiteral("Test Filter Items"), this); 0039 connect(testFilterItems, &QPushButton::clicked, this, [this]() { 0040 qDebug() << " Test Filter Items"; 0041 QList<qint64> itemIds; 0042 int set = 0; 0043 mMailFilterAgentInterface->filterItems(itemIds, static_cast<int>(set)); 0044 }); 0045 mainLayout->addWidget(testFilterItems); 0046 0047 auto testFilterItem = new QPushButton(QStringLiteral("Test Filter Item"), this); 0048 connect(testFilterItem, &QPushButton::clicked, this, [this]() { 0049 qDebug() << " Test Filter Item"; 0050 int set = 0; 0051 qlonglong item = 3; 0052 mMailFilterAgentInterface->filterItem(item, set, QStringLiteral("foo")); 0053 }); 0054 mainLayout->addWidget(testFilterItem); 0055 } 0056 0057 MailAgentDbusWidget::~MailAgentDbusWidget() = default; 0058 0059 #include "moc_mailagentdbuswidget.cpp"