reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

manager.hpp (2759B)


      1 /* ReaPack: Package manager for REAPER
      2  * Copyright (C) 2015-2025  Christian Fillion
      3  *
      4  * This program is free software: you can redistribute it and/or modify
      5  * it under the terms of the GNU Lesser General Public License as published by
      6  * the Free Software Foundation, either version 3 of the License, or
      7  * (at your option) any later version.
      8  *
      9  * This program is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12  * GNU Lesser General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU Lesser General Public License
     15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16  */
     17 
     18 #ifndef REAPACK_MANAGER_HPP
     19 #define REAPACK_MANAGER_HPP
     20 
     21 #include "dialog.hpp"
     22 
     23 #include <boost/logic/tribool.hpp>
     24 #include <map>
     25 #include <optional>
     26 
     27 class ListView;
     28 class Menu;
     29 class Remote;
     30 struct NetworkOpts;
     31 
     32 typedef boost::logic::tribool tribool;
     33 
     34 class Manager : public Dialog {
     35 public:
     36   Manager();
     37 
     38   void refresh();
     39   bool importRepo();
     40 
     41 protected:
     42   void onInit() override;
     43   void onCommand(int, int) override;
     44   bool onKeyDown(int, int) override;
     45   void onTimer(int) override;
     46   void onClose() override;
     47 
     48 private:
     49   struct RemoteMods {
     50     std::optional<bool> enable;
     51     std::optional<tribool> autoInstall;
     52     operator bool() const { return enable || autoInstall; }
     53   };
     54 
     55   typedef std::function<void (const Remote &, int index, RemoteMods *)> ModsCallback;
     56 
     57   Remote getRemote(int index) const;
     58   bool fillContextMenu(Menu &, int index) const;
     59   void setMods(const ModsCallback &);
     60   void toggleEnabled();
     61   bool isRemoteEnabled(const Remote &) const;
     62   void setRemoteAutoInstall(const tribool &);
     63   tribool remoteAutoInstall(const Remote &) const;
     64   void uninstall();
     65   void toggle(std::optional<bool> &, bool current);
     66   void refreshIndex();
     67   void copyUrl();
     68   void launchBrowser();
     69   void importExport();
     70   void options();
     71   void setupNetwork();
     72   void importArchive();
     73   void exportArchive();
     74   void aboutRepo(bool focus = true);
     75 
     76   void setChange(int);
     77   bool confirm() const;
     78   bool apply();
     79   void reset();
     80 
     81   HWND m_apply;
     82   ListView *m_list;
     83 
     84   size_t m_changes;
     85   bool m_importing;
     86 
     87   std::map<Remote, RemoteMods> m_mods;
     88   std::set<Remote> m_uninstall;
     89   std::optional<bool> m_autoInstall, m_bleedingEdge,
     90                       m_promptObsolete, m_expandSynonyms;
     91 
     92   Serializer m_serializer;
     93 };
     94 
     95 class NetworkConfig : public Dialog {
     96 public:
     97   NetworkConfig(NetworkOpts *);
     98 
     99 protected:
    100   void onInit() override;
    101   void onCommand(int, int) override;
    102 
    103 private:
    104   void apply();
    105 
    106   NetworkOpts *m_opts;
    107   HWND m_proxy;
    108   HWND m_staleThreshold;
    109   HWND m_verifyPeer;
    110 };
    111 
    112 #endif