/* * Copyright © 2016 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, 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 . * * Authors: * Ted Gould */ #pragma once #include "app-store-base.h" #include "glib-thread.h" #include "info-watcher-zg.h" #include "jobs-base.h" #include "registry.h" #include "snapd-info.h" #include #include #include #include #include #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #include #pragma GCC diagnostic pop namespace lomiri { namespace app_launch { class IconFinder; namespace app_store { class Base; } /** \private \brief Private implementation of the Registry object */ class Registry::Impl { public: Impl(); virtual ~Impl() { thread.quit(); } std::shared_ptr getClickManifest(const std::string& package); std::list getClickPackages(); std::string getClickDir(const std::string& package); static void setManager(const std::shared_ptr& manager, const std::shared_ptr& registry); void clearManager(); /** Shared context thread for events and background tasks that UAL subtasks are doing */ GLib::ContextThread thread; /** DBus shared connection for the session bus */ std::shared_ptr _dbus; /** Snapd information object */ snapd::Info snapdInfo; std::shared_ptr& getIconFinder(std::string basePath); virtual void zgSendEvent(AppID appid, const std::string& eventtype); static std::string printJson(std::shared_ptr jsonobj); static std::string printJson(std::shared_ptr jsonnode); /* Signal Hints */ /* NOTE: Static because we don't have registry instances in the C code right now. We want these to not be static in the future */ static void watchingAppStarting(bool rWatching); static bool isWatchingAppStarting(); const std::string& oomHelper() const { return oomHelper_; } std::shared_ptr getZgWatcher() { return zgWatcher_; } void setZgWatcher(const std::shared_ptr& watcher) { zgWatcher_ = watcher; } core::Signal&>& appInfoUpdated(); core::Signal&>& appAdded(); core::Signal& appRemoved(); const std::list>& appStores() { return _appStores; } void setAppStores(const std::list>& newlist) { _appStores = newlist; } const std::shared_ptr& jobs() { if (G_UNLIKELY(!jobs_)) { throw std::runtime_error{"Registry Implementation has no Jobs object"}; } return jobs_; } void setJobs(const std::shared_ptr& jobs) { jobs_ = jobs; } /* Create functions */ std::shared_ptr createApp(const AppID& appid); std::shared_ptr createHelper(const Helper::Type& type, const AppID& appid, const std::shared_ptr& sharedimpl); /* AppID functions */ AppID find(const std::string& sappid); AppID discover(const std::string& package, const std::string& appname, const std::string& version); AppID discover(const std::string& package, AppID::ApplicationWildcard appwildcard, AppID::VersionWildcard versionwildcard); AppID discover(const std::string& package, const std::string& appname, AppID::VersionWildcard versionwildcard); private: /** The job creation engine */ std::shared_ptr jobs_; std::shared_ptr _clickDB; std::shared_ptr _clickUser; void initClick(); /** Shared instance of the Zeitgeist Log */ std::shared_ptr zgLog_; /** All of our icon finders based on the path that they're looking into */ std::unordered_map> _iconFinders; std::mutex _iconFindersMutex; /** Path to the OOM Helper */ std::string oomHelper_; /** Application stores */ std::list> _appStores; /** Signal for application info changing */ core::Signal&> sig_appInfoUpdated; /** Signal for applications added */ core::Signal&> sig_appAdded; /** Signal for applications removed */ core::Signal sig_appRemoved; void infoWatchersSetup(const std::shared_ptr& reg); /** Flag to see if we've initialized the info watcher list */ std::once_flag flag_infoWatchersSetup; struct infoWatcherConnections { core::ScopedConnection infoUpdated; core::ScopedConnection appAdded; core::ScopedConnection appRemoved; }; /** List of info watchers along with a signal handle to our connection to their update signal */ std::list, infoWatcherConnections>> infoWatchers_; void infoWatchersSetup(); /** ZG Info Watcher */ std::shared_ptr zgWatcher_; }; } // namespace app_launch } // namespace lomiri