1 /*
2  *  Copyright (C) 2005-2020 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 "LockType.h"
12 #include "media/MediaLockState.h"
13 
14 #include <string>
15 #include <vector>
16 
17 /*!
18 \ingroup windows
19 \brief Represents a share.
20 \sa VECMediaSource, IVECSOURCES
21 */
22 class CMediaSource final
23 {
24 public:
25   enum SourceType
26   {
27     SOURCE_TYPE_UNKNOWN      = 0,
28     SOURCE_TYPE_LOCAL        = 1,
29     SOURCE_TYPE_DVD          = 2,
30     SOURCE_TYPE_VIRTUAL_DVD  = 3,
31     SOURCE_TYPE_REMOTE       = 4,
32     SOURCE_TYPE_VPATH        = 5,
33     SOURCE_TYPE_REMOVABLE    = 6
34   };
35 
36   bool operator==(const CMediaSource &right) const;
37 
38   void FromNameAndPaths(const std::string &category, const std::string &name, const std::vector<std::string> &paths);
39   bool IsWritable() const;
40   std::string strName; ///< Name of the share, can be chosen freely.
41   std::string strStatus; ///< Status of the share (eg has disk etc.)
42   std::string strDiskUniqueId; ///< removable:// + DVD Label + DVD ID for resume point storage, if available
43   std::string strPath; ///< Path of the share, eg. iso9660:// or F:
44 
45   /*!
46   \brief The type of the media source.
47 
48   Value can be:
49   - SOURCE_TYPE_UNKNOWN \n
50   Unknown source, maybe a wrong path.
51   - SOURCE_TYPE_LOCAL \n
52   Harddisk source.
53   - SOURCE_TYPE_DVD \n
54   DVD-ROM source of the build in drive, strPath may vary.
55   - SOURCE_TYPE_VIRTUAL_DVD \n
56   DVD-ROM source, strPath is fix.
57   - SOURCE_TYPE_REMOTE \n
58   Network source.
59   */
60   SourceType m_iDriveType = SOURCE_TYPE_UNKNOWN;
61 
62   /*!
63   \brief The type of Lock UI to show when accessing the media source.
64 
65   Value can be:
66   - CMediaSource::LOCK_MODE_EVERYONE \n
67   Default value.  No lock UI is shown, user can freely access the source.
68   - LOCK_MODE_NUMERIC \n
69   Lock code is entered via OSD numpad or IrDA remote buttons.
70   - LOCK_MODE_GAMEPAD \n
71   Lock code is entered via XBOX gamepad buttons.
72   - LOCK_MODE_QWERTY \n
73   Lock code is entered via OSD keyboard or PC USB keyboard.
74   - LOCK_MODE_SAMBA \n
75   Lock code is entered via OSD keyboard or PC USB keyboard and passed directly to SMB for authentication.
76   - LOCK_MODE_EEPROM_PARENTAL \n
77   Lock code is retrieved from XBOX EEPROM and entered via XBOX gamepad or remote.
78   - LOCK_MODE_UNKNOWN \n
79   Value is unknown or unspecified.
80   */
81   LockType m_iLockMode = LOCK_MODE_EVERYONE;
82   std::string m_strLockCode;  ///< Input code for Lock UI to verify, can be chosen freely.
83   int m_iHasLock = LOCK_STATE_NO_LOCK;
84   int m_iBadPwdCount = 0; ///< Number of wrong passwords user has entered since share was last unlocked
85 
86   std::string m_strThumbnailImage; ///< Path to a thumbnail image for the share, or blank for default
87 
88   std::vector<std::string> vecPaths;
89   bool m_ignore = false; /// <Do not store in xml
90   bool m_allowSharing = true; /// <Allow browsing of source from UPnP / WebServer
91 };
92 
93 /*!
94 \ingroup windows
95 \brief A vector to hold CMediaSource objects.
96 \sa CMediaSource, IVECSOURCES
97 */
98 typedef std::vector<CMediaSource> VECSOURCES;
99 
100 /*!
101 \ingroup windows
102 \brief Iterator of VECSOURCES.
103 \sa CMediaSource, VECSOURCES
104 */
105 typedef std::vector<CMediaSource>::iterator IVECSOURCES;
106 typedef std::vector<CMediaSource>::const_iterator CIVECSOURCES;
107 
108 void AddOrReplace(VECSOURCES& sources, const VECSOURCES& extras);
109 void AddOrReplace(VECSOURCES& sources, const CMediaSource& source);
110