summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/gui/GUIWindowAddonBrowser.h
blob: 7f605eefe32b00e303b037f5283e8968741f797f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
 *  Copyright (C) 2005-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include "ThumbLoader.h"
#include "addons/RepositoryUpdater.h"
#include "windows/GUIMediaWindow.h"

#include <string>
#include <vector>

class CFileItemList;

namespace ADDON
{
enum class AddonType;
struct AddonEvent;
}

class CGUIWindowAddonBrowser : public CGUIMediaWindow
{
public:
  CGUIWindowAddonBrowser(void);
  ~CGUIWindowAddonBrowser(void) override;
  bool OnMessage(CGUIMessage& message) override;

  /*!
   * @brief Popup a selection dialog with a list of addons of the given type
   *
   * @param[in] type the type of addon wanted
   * @param[in] addonID [in/out] the addon ID of the (pre) selected item
   * @param[in] showNone whether there should be a "None" item in the list (defaults to false)
   * @param[in] showDetails whether to show details of the addons or not
   * @param[in] showInstalled whether installed addons should be in the list
   * @param[in] showInstallable whether installable addons should be in the list
   * @param[in] showMore whether to show the "Get More" button (only makes sense
   *                     if showInstalled is true and showInstallable is false)
   * @return 1 if an addon was selected or multiple selection was specified, 2 if
   *         "Get More" was chosen, 0 if the selection process was cancelled or -1
   *         if an error occurred or
   */
  static int SelectAddonID(ADDON::AddonType type,
                           std::string& addonID,
                           bool showNone = false,
                           bool showDetails = true,
                           bool showInstalled = true,
                           bool showInstallable = false,
                           bool showMore = true);
  static int SelectAddonID(const std::vector<ADDON::AddonType>& types,
                           std::string& addonID,
                           bool showNone = false,
                           bool showDetails = true,
                           bool showInstalled = true,
                           bool showInstallable = false,
                           bool showMore = true);
  /*!
   * @brief Popup a selection dialog with a list of addons of the given type
   *
   * @param[in] type the type of addon wanted
   * @param[in] addonIDs [in/out] array of (pre) selected addon IDs
   * @param[in] showNone whether there should be a "None" item in the list (defaults to false)
   * @param[in] showDetails whether to show details of the addons or not
   * @param[in] multipleSelection allow selection of multiple addons, if set to
   *                              true showNone will automatically switch to false
   * @param[in] showInstalled whether installed addons should be in the list
   * @param[in] showInstallable whether installable addons should be in the list
   * @param[in] showMore whether to show the "Get More" button (only makes sense
   *                     if showInstalled is true and showInstallable is false)
   * @return 1 if an addon was selected or multiple selection was specified, 2 if
   *         "Get More" was chosen, 0 if the selection process was cancelled or -1
   *         if an error occurred or
   */
  static int SelectAddonID(ADDON::AddonType type,
                           std::vector<std::string>& addonIDs,
                           bool showNone = false,
                           bool showDetails = true,
                           bool multipleSelection = true,
                           bool showInstalled = true,
                           bool showInstallable = false,
                           bool showMore = true);
  static int SelectAddonID(const std::vector<ADDON::AddonType>& types,
                           std::vector<std::string>& addonIDs,
                           bool showNone = false,
                           bool showDetails = true,
                           bool multipleSelection = true,
                           bool showInstalled = true,
                           bool showInstallable = false,
                           bool showMore = true);

  bool UseFileDirectories() override { return false; }

  static void InstallFromZip();

protected:
  bool OnClick(int iItem, const std::string& player = "") override;
  void UpdateButtons() override;
  bool GetDirectory(const std::string& strDirectory, CFileItemList& items) override;
  bool Update(const std::string& strDirectory, bool updateFilterPath = true) override;
  std::string GetStartFolder(const std::string& dir) override;

  std::string GetRootPath() const override { return "addons://"; }

private:
  void SetProperties();
  void UpdateStatus(const CFileItemPtr& item);
  void OnEvent(const ADDON::CRepositoryUpdater::RepositoryUpdated& event);
  void OnEvent(const ADDON::AddonEvent& event);
  CProgramThumbLoader m_thumbLoader;
};