2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
22 #include "GUIInfoManager.h"
23 #include "utils/XMLUtils.h"
25 CProfile::CLock::CLock(LockType type, const CStdString &password)
32 settings = LOCK_LEVEL::NONE;
38 void CProfile::CLock::Validate()
40 if (mode != LOCK_MODE_EVERYONE && (code == "-" || code.empty()))
41 mode = LOCK_MODE_EVERYONE;
43 if (code.empty() || mode == LOCK_MODE_EVERYONE)
47 CProfile::CProfile(const CStdString &directory, const CStdString &name, const int id)
50 m_directory = directory;
55 m_bCanWriteSources = true;
59 CProfile::~CProfile(void)
62 void CProfile::setDate()
64 CStdString strDate = g_infoManager.GetDate(true);
65 CStdString strTime = g_infoManager.GetTime();
66 if (strDate.empty() || strTime.empty())
69 setDate(strDate+" - "+strTime);
72 void CProfile::Load(const TiXmlNode *node, int nextIdProfile)
74 if (!XMLUtils::GetInt(node, "id", m_id))
77 XMLUtils::GetString(node, "name", m_name);
78 XMLUtils::GetPath(node, "directory", m_directory);
79 XMLUtils::GetPath(node, "thumbnail", m_thumb);
80 XMLUtils::GetBoolean(node, "hasdatabases", m_bDatabases);
81 XMLUtils::GetBoolean(node, "canwritedatabases", m_bCanWrite);
82 XMLUtils::GetBoolean(node, "hassources", m_bSources);
83 XMLUtils::GetBoolean(node, "canwritesources", m_bCanWriteSources);
84 XMLUtils::GetBoolean(node, "lockaddonmanager", m_locks.addonManager);
85 XMLUtils::GetInt(node, "locksettings", (int&)m_locks.settings);
86 XMLUtils::GetBoolean(node, "lockfiles", m_locks.files);
87 XMLUtils::GetBoolean(node, "lockmusic", m_locks.music);
88 XMLUtils::GetBoolean(node, "lockvideo", m_locks.video);
89 XMLUtils::GetBoolean(node, "lockpictures", m_locks.pictures);
90 XMLUtils::GetBoolean(node, "lockprograms", m_locks.programs);
92 int lockMode = m_locks.mode;
93 XMLUtils::GetInt(node, "lockmode", lockMode);
94 m_locks.mode = (LockType)lockMode;
95 if (m_locks.mode > LOCK_MODE_QWERTY || m_locks.mode < LOCK_MODE_EVERYONE)
96 m_locks.mode = LOCK_MODE_EVERYONE;
98 XMLUtils::GetString(node, "lockcode", m_locks.code);
99 XMLUtils::GetString(node, "lastdate", m_date);
102 void CProfile::Save(TiXmlNode *root) const
104 TiXmlElement profileNode("profile");
105 TiXmlNode *node = root->InsertEndChild(profileNode);
107 XMLUtils::SetInt(node, "id", m_id);
108 XMLUtils::SetString(node, "name", m_name);
109 XMLUtils::SetPath(node, "directory", m_directory);
110 XMLUtils::SetPath(node, "thumbnail", m_thumb);
111 XMLUtils::SetBoolean(node, "hasdatabases", m_bDatabases);
112 XMLUtils::SetBoolean(node, "canwritedatabases", m_bCanWrite);
113 XMLUtils::SetBoolean(node, "hassources", m_bSources);
114 XMLUtils::SetBoolean(node, "canwritesources", m_bCanWriteSources);
115 XMLUtils::SetBoolean(node, "lockaddonmanager", m_locks.addonManager);
116 XMLUtils::SetInt(node, "locksettings", m_locks.settings);
117 XMLUtils::SetBoolean(node, "lockfiles", m_locks.files);
118 XMLUtils::SetBoolean(node, "lockmusic", m_locks.music);
119 XMLUtils::SetBoolean(node, "lockvideo", m_locks.video);
120 XMLUtils::SetBoolean(node, "lockpictures", m_locks.pictures);
121 XMLUtils::SetBoolean(node, "lockprograms", m_locks.programs);
123 XMLUtils::SetInt(node, "lockmode", m_locks.mode);
124 XMLUtils::SetString(node,"lockcode", m_locks.code);
125 XMLUtils::SetString(node, "lastdate", m_date);
128 void CProfile::SetLocks(const CProfile::CLock &locks)