File indexing completed on 2024-06-23 05:06:33

0001 /*
0002     SPDX-FileCopyrightText: 2010 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "agentpluginloader.h"
0010 
0011 #include <QHash>
0012 #include <QObject>
0013 #include <QQueue>
0014 
0015 namespace Akonadi
0016 {
0017 class AgentThread;
0018 
0019 class AgentServer : public QObject
0020 {
0021     Q_OBJECT
0022     Q_CLASSINFO("D-Bus Interface", "org.freedesktop.Akonadi.AgentServer")
0023 
0024     using ConfigureInfo = QPair<QString, qlonglong>;
0025 
0026 public:
0027     explicit AgentServer(QObject *parent = nullptr);
0028     ~AgentServer() override;
0029 
0030 public Q_SLOTS:
0031     Q_SCRIPTABLE void agentInstanceConfigure(const QString &identifier, qlonglong windowId);
0032     Q_SCRIPTABLE bool started(const QString &identifier) const;
0033     Q_SCRIPTABLE void startAgent(const QString &identifier, const QString &typeIdentifier, const QString &fileName);
0034     Q_SCRIPTABLE void stopAgent(const QString &identifier);
0035     Q_SCRIPTABLE void quit();
0036 
0037 private Q_SLOTS:
0038     void processConfigureRequest();
0039 
0040 private:
0041     QHash<QString, AgentThread *> m_agents;
0042     QQueue<ConfigureInfo> m_configureQueue;
0043     AgentPluginLoader m_agentLoader;
0044     bool m_processingConfigureRequests = false;
0045     bool m_quiting = false;
0046 };
0047 
0048 }