xbmc
MediaSourceSettings.h
1 /*
2  * Copyright (C) 2013-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 "MediaSource.h"
12 #include "settings/lib/ISettingsHandler.h"
13 
14 #include <string>
15 
16 class CProfileManager;
17 
18 namespace tinyxml2
19 {
20 class XMLNode;
21 }
22 
24 {
25 public:
26  static CMediaSourceSettings& GetInstance();
27 
28  static std::string GetSourcesFile();
29 
30  void OnSettingsLoaded() override;
31  void OnSettingsUnloaded() override;
32 
33  bool Load();
34  bool Load(const std::string &file);
35  bool Save();
36  bool Save(const std::string &file) const;
37  void Clear();
38 
39  VECSOURCES* GetSources(const std::string &type);
40  const std::string& GetDefaultSource(const std::string &type) const;
41  void SetDefaultSource(const std::string &type, const std::string &source);
42 
43  bool UpdateSource(const std::string &strType, const std::string &strOldName, const std::string &strUpdateChild, const std::string &strUpdateValue);
44  bool DeleteSource(const std::string &strType, const std::string &strName, const std::string &strPath, bool virtualSource = false);
45  bool AddShare(const std::string &type, const CMediaSource &share);
46  bool UpdateShare(const std::string &type, const std::string &oldName, const CMediaSource &share);
47 
48 protected:
51  CMediaSourceSettings& operator=(CMediaSourceSettings const&) = delete;
52  ~CMediaSourceSettings() override;
53 
54 private:
55  bool GetSource(const std::string& category, const tinyxml2::XMLNode* source, CMediaSource& share);
56  void GetSources(const tinyxml2::XMLNode* rootElement,
57  const std::string& tagName,
58  VECSOURCES& items,
59  std::string& defaultString);
60  bool SetSources(tinyxml2::XMLNode* rootNode,
61  const char* section,
62  const VECSOURCES& shares,
63  const std::string& defaultPath) const;
64 
65  VECSOURCES m_programSources;
66  VECSOURCES m_pictureSources;
67  VECSOURCES m_fileSources;
68  VECSOURCES m_musicSources;
69  VECSOURCES m_videoSources;
70  VECSOURCES m_gameSources;
71 
72  std::string m_defaultProgramSource;
73  std::string m_defaultMusicSource;
74  std::string m_defaultPictureSource;
75  std::string m_defaultFileSource;
76 };
Definition: MediaSourceSettings.h:23
Definition: SkinTimerManager.h:18
Represents a share.
Definition: MediaSource.h:22
Definition: ProfileManager.h:25
Interface defining methods being called by the settings system if an action is performed on multiple/...
Definition: ISettingsHandler.h:16