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 class TiXmlNode;
18 
20 {
21 public:
22  static CMediaSourceSettings& GetInstance();
23 
24  static std::string GetSourcesFile();
25 
26  void OnSettingsLoaded() override;
27  void OnSettingsUnloaded() override;
28 
29  bool Load();
30  bool Load(const std::string &file);
31  bool Save();
32  bool Save(const std::string &file) const;
33  void Clear();
34 
35  VECSOURCES* GetSources(const std::string &type);
36  const std::string& GetDefaultSource(const std::string &type) const;
37  void SetDefaultSource(const std::string &type, const std::string &source);
38 
39  bool UpdateSource(const std::string &strType, const std::string &strOldName, const std::string &strUpdateChild, const std::string &strUpdateValue);
40  bool DeleteSource(const std::string &strType, const std::string &strName, const std::string &strPath, bool virtualSource = false);
41  bool AddShare(const std::string &type, const CMediaSource &share);
42  bool UpdateShare(const std::string &type, const std::string &oldName, const CMediaSource &share);
43 
44 protected:
47  CMediaSourceSettings& operator=(CMediaSourceSettings const&) = delete;
48  ~CMediaSourceSettings() override;
49 
50 private:
51  bool GetSource(const std::string &category, const TiXmlNode *source, CMediaSource &share);
52  void GetSources(const TiXmlNode* pRootElement, const std::string& strTagName, VECSOURCES& items, std::string& strDefault);
53  bool SetSources(TiXmlNode *root, const char *section, const VECSOURCES &shares, const std::string &defaultPath) const;
54 
55  VECSOURCES m_programSources;
56  VECSOURCES m_pictureSources;
57  VECSOURCES m_fileSources;
58  VECSOURCES m_musicSources;
59  VECSOURCES m_videoSources;
60  VECSOURCES m_gameSources;
61 
62  std::string m_defaultProgramSource;
63  std::string m_defaultMusicSource;
64  std::string m_defaultPictureSource;
65  std::string m_defaultFileSource;
66 };
Definition: MediaSourceSettings.h:19
Represents a share.
Definition: MediaSource.h:22
void OnSettingsUnloaded() override
Setting values have been unloaded.
Definition: MediaSourceSettings.cpp:63
Definition: ProfileManager.h:25
Interface defining methods being called by the settings system if an action is performed on multiple/...
Definition: ISettingsHandler.h:16
void OnSettingsLoaded() override
Settings have been loaded.
Definition: MediaSourceSettings.cpp:58