kodi
GUIDialogAddonInfo.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "addons/addoninfo/AddonInfo.h"
12 #include "guilib/GUIDialog.h"
13 
14 #include <memory>
15 #include <string>
16 #include <utility>
17 #include <vector>
18 
19 namespace ADDON
20 {
21 class IAddon;
22 using AddonPtr = std::shared_ptr<IAddon>;
23 
24 } // namespace ADDON
25 
26 enum class Reactivate : bool
27 {
28  CHOICE_YES = true,
29  CHOICE_NO = false,
30 };
31 
32 enum class PerformButtonFocus : bool
33 {
34  CHOICE_YES = true,
35  CHOICE_NO = false,
36 };
37 
38 enum class EntryPoint : int
39 {
40  INSTALL,
41  UPDATE,
42  SHOW_DEPENDENCIES,
43 };
44 
46 {
48  const std::shared_ptr<ADDON::IAddon>& installed,
49  const std::shared_ptr<ADDON::IAddon>& available)
50  : m_depInfo(depInfo), m_installed(installed), m_available(available)
51  {
52  }
53 
58  bool IsInstalledUpToDate() const;
59 
60  ADDON::DependencyInfo m_depInfo;
61  std::shared_ptr<ADDON::IAddon> m_installed;
62  std::shared_ptr<ADDON::IAddon> m_available;
63 };
64 
66 {
67 public:
68  CGUIDialogAddonInfo(void);
69  ~CGUIDialogAddonInfo(void) override;
70  bool OnMessage(CGUIMessage& message) override;
71  bool OnAction(const CAction& action) override;
72 
73  CFileItemPtr GetCurrentListItem(int offset = 0) override { return m_item; }
74  bool HasListItems() const override { return true; }
75 
76  static bool ShowForItem(const CFileItemPtr& item);
77 
78 private:
79  void OnInitWindow() override;
80 
87  bool SetItem(const CFileItemPtr& item);
88  void UpdateControls(PerformButtonFocus performButtonFocus);
89 
90  void OnUpdate();
91  void OnSelectVersion();
92  void OnInstall();
93  void OnUninstall();
94  void OnEnableDisable();
95  void OnSettings();
96  void OnSelect();
97  void OnToggleAutoUpdates();
98  int AskForVersion(std::vector<std::pair<ADDON::CAddonVersion, std::string>>& versions);
99 
103  bool CanOpen() const;
104 
108  bool CanRun() const;
109 
114  bool CanUse() const;
115 
119  bool CanShowSupportList() const;
120 
128  bool PromptIfDependency(int heading, int line2);
129 
137  bool ShowDependencyList(Reactivate reactivate, EntryPoint entryPoint);
138 
142  void ShowSupportList();
143 
147  void BuildDependencyList();
148 
149  CFileItemPtr m_item;
150  ADDON::AddonPtr m_localAddon;
151  bool m_addonEnabled = false;
152 
157  bool m_silentUninstall = false;
158 
159  bool m_showDepDialogOnInstall = false;
160  std::vector<ADDON::DependencyInfo> m_deps;
161  std::vector<CInstalledWithAvailable> m_depsInstalledWithAvailable;
162 };
Definition: AddonInfo.h:108
Definition: GUIDialogAddonInfo.h:45
Class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:21
Definition: GUIDialog.h:35
Definition: GUIDialogAddonInfo.h:65
Definition: GUIMessage.h:365
Definition: Addon.cpp:39