Page MenuHomePhabricator

No OneTemporary

Size
6 KB
Referenced Files
None
Subscribers
None
diff --git a/trunk/settings.cpp b/trunk/settings.cpp
index e874cad..64de331 100644
--- a/trunk/settings.cpp
+++ b/trunk/settings.cpp
@@ -1,62 +1,89 @@
/*******************************************************************************
* fred Copyright (c) 2011-2013 by Gillen Daniel <gillen.dan@pinguin.lu> *
* *
* Forensic Registry EDitor (fred) is a cross-platform M$ registry hive editor *
* with special feautures useful during forensic analysis. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation, either version 3 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************/
#include "settings.h"
#include <QDir>
#ifndef FRED_REPORT_TEMPLATE_DIR
#ifndef __MINGW32__
- #define FRED_REPORT_TEMPLATE_DIR "/usr/share/fred/report_templates/"
+ #define SYSTEM_REPORT_TEMPLATE_DIR "/usr/share/fred/report_templates/"
#else
- #define FRED_REPORT_TEMPLATE_DIR ".\\report_templates\\"
+ #define SYSTEM_REPORT_TEMPLATE_DIR ".\\report_templates\\"
#endif
#endif
#define APP_ORGANIZATION "pinguin.lu"
#define APP_NAME "fred"
-settings::settings(QObject *p_parent) : QObject(p_parent) {
+Settings::Settings(QObject *p_parent) : QObject(p_parent) {
// Init vars
this->p_settings=NULL;
this->user_settings_dir=QDir::homePath()
.append(QDir::separator()).append(".fred");
+ this->user_report_template_dir=QString(this->user_settings_dir)
+ .append(QDir::separator())
+ .append("report_templates");
}
-bool settings::Init() {
- // Make sure config dir exists
+bool Settings::Init() {
+ // Make sure config dirs exist
if(!QDir(this->user_settings_dir).exists()) {
// User config dir does not exists, try to create it
if(!QDir().mkpath(this->user_settings_dir)) {
// TODO: Maybe warn user
return false;
}
+ }
+ if(!QDir(this->user_report_template_dir).exists()) {
// Create config dir sub folder for report templates
- user_config_dir.append(QDir::separator()).append("report_templates");
- if(!QDir().mkpath(user_config_dir)) {
+ if(!QDir().mkpath(this->user_report_template_dir)) {
// TODO: Maybe warn user
return false;
}
}
- this->p_settings=new QSettings(APP_ORGANIZATION,APP_NAME,this);
+#ifndef __MINGW32__
+ // On any Unix-like OS, settings should be saved in the .fred folder
+ QSettings::setPath(QSettings::NativeFormat,
+ QSettings::UserScope,
+ this->user_settings_dir);
+#endif
+
+ // Create / open settings
+ this->p_settings=new QSettings(QSettings::NativeFormat,
+ QSettings::UserScope,
+ APP_ORGANIZATION,
+ APP_NAME,
+ this);
+ if(this->p_settings->status()!=QSettings::NoError ||
+ !this->p_settings->isWritable())
+ {
+ return false;
+ }
+
+ return true;
}
+QStringList Settings::GetReportTemplateDirs() {
+ return QStringList()<<SYSTEM_REPORT_TEMPLATE_DIR
+ <<this->user_report_template_dir;
+}
diff --git a/trunk/settings.h b/trunk/settings.h
index e0a25aa..c9db10c 100644
--- a/trunk/settings.h
+++ b/trunk/settings.h
@@ -1,40 +1,44 @@
/*******************************************************************************
* fred Copyright (c) 2011-2013 by Gillen Daniel <gillen.dan@pinguin.lu> *
* *
* Forensic Registry EDitor (fred) is a cross-platform M$ registry hive editor *
* with special feautures useful during forensic analysis. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation, either version 3 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************/
#ifndef SETTINGS_H
#define SETTINGS_H
#include <QObject>
#include <QSettings>
#include <QString>
+#include <QStringList>
-class settings : public QObject {
+class Settings : public QObject {
Q_OBJECT
public:
- explicit settings(QObject *p_parent=0);
+ explicit Settings(QObject *p_parent=0);
+ bool Init();
+ QStringList GetReportTemplateDirs();
private:
QSettings *p_settings;
QString user_settings_dir;
+ QString user_report_template_dir;
};
#endif // SETTINGS_H

File Metadata

Mime Type
text/x-diff
Expires
Tue, Dec 24, 3:07 AM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1176972
Default Alt Text
(6 KB)

Event Timeline