// SPDX-License-Identifier: GPL-3.0-or-later // Copyright 2019 Juan Palacios #pragma once #include "iprofile.h" #include "isession.h" #include #include #include #include #include #include #include #include class IProfileApplicator; class IProfileView; class IProfileViewFactory; class IHelperMonitor; class Session final : public ISession { public: Session(std::shared_ptr profileApplicator, std::unique_ptr &&profileManager, std::unique_ptr &&profileViewFactory, std::unique_ptr &&helperMonitor, bool logProfileStack = false) noexcept; void addManualProfileObserver( std::shared_ptr observer) override; void removeManualProfileObserver( std::shared_ptr observer) override; void init(ISysModel const &model) override; bool toggleManualProfile(std::string const &profileName) override; bool activateManualProfile(std::string const &profileName) override; bool deactivateManualProfile(std::string const &profileName) override; IProfileManager &profileManager() const override; void logProfileStack(bool enable) override; private: void profileAdded(std::string const &profileName); void profileRemoved(std::string const &profileName); void profileChanged(std::string const &profileName); void profileActiveChanged(std::string const &profileName, bool active); void profileSaved(std::string const &profileName); void profileInfoChanged(IProfile::Info const &oldInfo, IProfile::Info const &newInfo); void queueProfileViewForExecutable(std::string const &executableName); void dequeueProfileViewForExecutable(std::string const &executableName); void populateProfileExeIndex(); void watchProfiles(); void createProfileViews( std::optional> baseProfileView, std::vector const &profileNames); void queueProfileView(std::string const &profileName); void dequeueProfileView(std::string const &profileName); void notifyManualProfileToggled(std::string const &profileName, bool active); void logProfileStack() const; std::shared_ptr profileApplicator_; std::unique_ptr profileManager_; std::unique_ptr profileViewFactory_; std::unique_ptr helperMonitor_; class ProfileManagerObserver; std::shared_ptr const profileManagerObserver_; class HelperMonitorObserver; std::shared_ptr const helperMonitorObserver_; std::optional manualProfile_; std::mutex manualProfileMutex_; std::deque> pViews_; std::mutex pViewsMutex_; using executableName = std::string; using profileName = std::string; std::unordered_map profileExeIndex_; std::mutex profileExeIndexMutex_; std::vector> manualProfileObservers_; std::mutex manualProfileObserversMutex_; bool logProfileStack_; };