// Squawk messenger. // Copyright (C) 2019 Yury Gubich // // 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 3 of the License, or // (at your option) any later version. // // 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, see . #ifndef CORE_DELAYMANAGER_H #define CORE_DELAYMANAGER_H #include #include #include #include #include #include namespace Core { class DelayManager : public QObject { Q_OBJECT enum class TaskType { cardInternal, infoForUser } public: DelayManager(uint16_t maxParallelJobs = 5, QObject* parent = nullptr); ~DelayManager(); void requestVCard(const QString& jid); void requestInfo(const QString& jid); signals: void requestVCard(const QString& jid); public slots: void receivedVCard(const QString& jid, const Shared::VCard& card); private: typedef std::pair Job; void scheduleJob(TaskType type, void* data); void executeJob(Job job); void jobIsDone(uint16_t jobId); private: uint16_t maxParallelJobs; uint16_t nextJobId; std::list scheduledJobs; std::map runningJobs; std::set pendingVCards; std::map requestedVCards; }; } #endif // CORE_DELAYMANAGER_H