[Windows] Remove redundant DirectSound error codes
[xbmc.git] / xbmc / profiles / Profile.cpp
blobf0614f2630dde0d1081cdc2dfa4e7e41d1f5f318
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "Profile.h"
11 #include "XBDateTime.h"
12 #include "utils/XMLUtils.h"
14 CProfile::CLock::CLock(LockType type, const std::string& password)
15 : mode(type), code(password), settings(LOCK_LEVEL::NONE)
17 programs = false;
18 pictures = false;
19 files = false;
20 video = false;
21 music = false;
22 addonManager = false;
23 games = false;
26 void CProfile::CLock::Validate()
28 if (mode != LOCK_MODE_EVERYONE && (code == "-" || code.empty()))
29 mode = LOCK_MODE_EVERYONE;
31 if (code.empty() || mode == LOCK_MODE_EVERYONE)
32 code = "-";
35 CProfile::CProfile(const std::string &directory, const std::string &name, const int id):
36 m_directory(directory),
37 m_name(name)
39 m_id = id;
40 m_bDatabases = true;
41 m_bCanWrite = true;
42 m_bSources = true;
43 m_bCanWriteSources = true;
44 m_bAddons = true;
47 CProfile::~CProfile(void) = default;
49 void CProfile::setDate()
51 const CDateTime now = CDateTime::GetCurrentDateTime();
52 std::string strDate = now.GetAsLocalizedDate(false);
53 std::string strTime = now.GetAsLocalizedTime(TIME_FORMAT_GUESS);
54 if (strDate.empty() || strTime.empty())
55 setDate("-");
56 else
57 setDate(strDate+" - "+strTime);
60 void CProfile::Load(const TiXmlNode *node, int nextIdProfile)
62 if (!XMLUtils::GetInt(node, "id", m_id))
63 m_id = nextIdProfile;
65 XMLUtils::GetString(node, "name", m_name);
66 XMLUtils::GetPath(node, "directory", m_directory);
67 XMLUtils::GetPath(node, "thumbnail", m_thumb);
68 XMLUtils::GetBoolean(node, "hasdatabases", m_bDatabases);
69 XMLUtils::GetBoolean(node, "canwritedatabases", m_bCanWrite);
70 XMLUtils::GetBoolean(node, "hassources", m_bSources);
71 XMLUtils::GetBoolean(node, "canwritesources", m_bCanWriteSources);
72 XMLUtils::GetBoolean(node, "lockaddonmanager", m_locks.addonManager);
73 int settings = m_locks.settings;
74 XMLUtils::GetInt(node, "locksettings", settings);
75 m_locks.settings = (LOCK_LEVEL::SETTINGS_LOCK)settings;
76 XMLUtils::GetBoolean(node, "lockfiles", m_locks.files);
77 XMLUtils::GetBoolean(node, "lockmusic", m_locks.music);
78 XMLUtils::GetBoolean(node, "lockvideo", m_locks.video);
79 XMLUtils::GetBoolean(node, "lockpictures", m_locks.pictures);
80 XMLUtils::GetBoolean(node, "lockprograms", m_locks.programs);
81 XMLUtils::GetBoolean(node, "lockgames", m_locks.games);
83 int lockMode = m_locks.mode;
84 XMLUtils::GetInt(node, "lockmode", lockMode);
85 m_locks.mode = (LockType)lockMode;
86 if (m_locks.mode > LOCK_MODE_QWERTY || m_locks.mode < LOCK_MODE_EVERYONE)
87 m_locks.mode = LOCK_MODE_EVERYONE;
89 XMLUtils::GetString(node, "lockcode", m_locks.code);
90 XMLUtils::GetString(node, "lastdate", m_date);
93 void CProfile::Save(TiXmlNode *root) const
95 TiXmlElement profileNode("profile");
96 TiXmlNode *node = root->InsertEndChild(profileNode);
98 XMLUtils::SetInt(node, "id", m_id);
99 XMLUtils::SetString(node, "name", m_name);
100 XMLUtils::SetPath(node, "directory", m_directory);
101 XMLUtils::SetPath(node, "thumbnail", m_thumb);
102 XMLUtils::SetBoolean(node, "hasdatabases", m_bDatabases);
103 XMLUtils::SetBoolean(node, "canwritedatabases", m_bCanWrite);
104 XMLUtils::SetBoolean(node, "hassources", m_bSources);
105 XMLUtils::SetBoolean(node, "canwritesources", m_bCanWriteSources);
106 XMLUtils::SetBoolean(node, "lockaddonmanager", m_locks.addonManager);
107 XMLUtils::SetInt(node, "locksettings", m_locks.settings);
108 XMLUtils::SetBoolean(node, "lockfiles", m_locks.files);
109 XMLUtils::SetBoolean(node, "lockmusic", m_locks.music);
110 XMLUtils::SetBoolean(node, "lockvideo", m_locks.video);
111 XMLUtils::SetBoolean(node, "lockpictures", m_locks.pictures);
112 XMLUtils::SetBoolean(node, "lockprograms", m_locks.programs);
113 XMLUtils::SetBoolean(node, "lockgames", m_locks.games);
115 XMLUtils::SetInt(node, "lockmode", m_locks.mode);
116 XMLUtils::SetString(node,"lockcode", m_locks.code);
117 XMLUtils::SetString(node, "lastdate", m_date);
120 void CProfile::SetLocks(const CProfile::CLock &locks)
122 m_locks = locks;
123 m_locks.Validate();