summaryrefslogtreecommitdiffstats
path: root/src/vsession.cpp
diff options
context:
space:
mode:
authorSimon Rettberg2019-07-09 15:49:44 +0200
committerSimon Rettberg2019-07-09 15:49:44 +0200
commit7a8be902d21f5cf84ef74633a2dda910af3699a1 (patch)
treefd32c55e1ef76152159d4fed00f7992a15829aa1 /src/vsession.cpp
parentRemove call to abort() causing Qt debug spam (diff)
downloadvmchooser2-7a8be902d21f5cf84ef74633a2dda910af3699a1.tar.gz
vmchooser2-7a8be902d21f5cf84ef74633a2dda910af3699a1.tar.xz
vmchooser2-7a8be902d21f5cf84ef74633a2dda910af3699a1.zip
Rewrite list/news/help download and backup file handling
Diffstat (limited to 'src/vsession.cpp')
-rw-r--r--src/vsession.cpp57
1 files changed, 4 insertions, 53 deletions
diff --git a/src/vsession.cpp b/src/vsession.cpp
index 78185e4..b86f314 100644
--- a/src/vsession.cpp
+++ b/src/vsession.cpp
@@ -285,64 +285,15 @@ int VSession::type() const {
return Session::VSESSION;
}
-QList<Session*> VSession::readXmlFile(const QString& filepath) {
+QList<Session*> VSession::loadFromXmlDocument(const QDomDocument& doc) {
QList<Session*> sessionList;
-
- QDomDocument doc;
- QFile file(filepath);
- QFile backup_file(TEMP_PATH_XML_LIST);
-
- if (!file.open(QIODevice::ReadOnly)) {
- if (g_debugMode) {
- qDebug() << "Cannot read file: " << file.fileName();
- }
+ if (doc.isNull())
return sessionList;
- }
-
- if (!doc.setContent(&file)) {
- if (g_debugMode) {
- qDebug() << "XML file not valid: " << file.fileName();
- }
-
- file.close();
-
- // try to use backup file
- if (!backup_file.open(QIODevice::ReadOnly)) {
- if (g_debugMode) {
- qDebug() << "Cannot read backup file " << TEMP_PATH_XML_LIST << " either";
- }
- return sessionList;
- }
-
- if (!doc.setContent(&backup_file)) {
- if (g_debugMode) {
- qDebug() << "XML file not valid: " << backup_file.fileName();
- }
- backup_file.close();
- return sessionList;
- }
-
- if (g_debugMode) {
- qDebug() << "Used backup file " << TEMP_PATH_XML_LIST;
- }
-
- backup_file.close();
- } else {
- file.close();
-
- // file is valid --> create backup file
- QFile::remove(TEMP_PATH_XML_LIST);
- QFile::rename(filepath, TEMP_PATH_XML_LIST);
- if (!QFile::setPermissions(TEMP_PATH_XML_LIST, QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther)) {
- if (g_debugMode) {
- qDebug() << "Could not change permissions of file: " << TEMP_PATH_NEWS;
- }
- }
- }
UserLdapData::init();
-
QDomElement settingsNode = doc.firstChildElement(QStringLiteral("settings"));
+ if (settingsNode.isNull())
+ return sessionList;
for (QDomElement el(settingsNode.firstChildElement(QStringLiteral("eintrag")));
!el.isNull();
el = el.nextSiblingElement(QStringLiteral("eintrag"))) {