1 #include "fd-config-ui-controller.h"
2 
FdConfigUiController(QObject * parent)3 FdConfigUiController::FdConfigUiController(QObject *parent):
4     QObject(parent)
5 {}
6 
readFileDaemonConfig()7 void FdConfigUiController::readFileDaemonConfig()
8 {
9     QString fileName = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
10             + "/etc/bacula-fd.conf";
11     if (QFile::exists(fileName)) {
12         QFile file(fileName);
13         if (file.open(QFile::ReadOnly)) {
14             QTextStream stream(&file);
15             QString fdConfig = stream.readAll();
16             file.close();
17             emit fileDaemonConfigRead(fdConfig);
18         }
19     } else {
20         emit fileDaemonConfigRead("ERROR - File Daemon config file not found");
21     }
22 }
23 
writeFileDaemonConfig(QString fcontents)24 void FdConfigUiController::writeFileDaemonConfig(QString fcontents)
25 {
26 
27     QString filePath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
28             + "/etc/bacula-fd.conf";
29     QFile file(filePath);
30 
31     if (!file.open(QFile::WriteOnly | QFile::Truncate | QFile::Text)) {
32         return;
33     }
34 
35     file.write(fcontents.toUtf8().constData());
36     file.close();
37 }
38 
~FdConfigUiController()39 FdConfigUiController::~FdConfigUiController()
40 {}
41