diff --git a/src/model/CMakeLists.txt b/src/model/CMakeLists.txt index 8954f15..37c6675 100644 --- a/src/model/CMakeLists.txt +++ b/src/model/CMakeLists.txt @@ -1,3 +1,5 @@ +find_package(Qt5 COMPONENTS Core REQUIRED) + set(HEADERS common.h model.h @@ -21,6 +23,9 @@ set(HEADERS admx/supporteddefinition.h admx/supportedon.h admx/supportedproduct.h + bundle/policybundle.h + bundle/policytreemodel.h + bundle/policytreemodelitem.h presentation/checkbox.h presentation/combobox.h presentation/decimaltextbox.h @@ -38,7 +43,8 @@ set(HEADERS set(SOURCES model.cpp - presentation/presentationwidget.cpp + bundle/policybundle.cpp + presentation/presentationwidget.cpp ) add_definitions( @@ -46,4 +52,4 @@ add_definitions( ) add_gpui_library(gpui-model ${SOURCES}) -target_link_libraries(gpui-model) +target_link_libraries(gpui-model Qt5::Core) diff --git a/src/model/bundle/policybundle.cpp b/src/model/bundle/policybundle.cpp new file mode 100644 index 0000000..a3b6fcc --- /dev/null +++ b/src/model/bundle/policybundle.cpp @@ -0,0 +1,68 @@ +/*********************************************************************************************************************** +** +** Copyright (C) 2021 BaseALT Ltd. +** +** 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 2 +** 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, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +** +***********************************************************************************************************************/ + +#include "policybundle.h" + +#include + +namespace model { + +namespace bundle { + +PolicyBundle::PolicyBundle(const ILogger& logger) +{ + Q_UNUSED(logger); +} + +std::shared_ptr PolicyBundle::loadFolder(const std::string& path, const std::string& language, + const std::string& fallbackLanguage) +{ + const QDir dir(path.c_str()); + const QFileInfoList files = dir.entryInfoList(); + + for (const QFileInfo& file : files) { + if (file.completeBaseName().toLower().endsWith(".admx")) { + loadAdmxAndAdml(file, language, fallbackLanguage); + } + } + + return std::shared_ptr(nullptr); +} + +bool PolicyBundle::loadAdmxAndAdml(const QFileInfo& admxFileName, const std::string& language, + const std::string& fallbackLanguage) +{ + Q_UNUSED(admxFileName); + Q_UNUSED(language); + Q_UNUSED(fallbackLanguage); + + // TODO: Load admx and adml files. + return false; +} + +void PolicyBundle::logError(const std::string& error) +{ + Q_UNUSED(error); + // TODO: Implement logging. +} + +} + +} diff --git a/src/model/bundle/policybundle.h b/src/model/bundle/policybundle.h new file mode 100644 index 0000000..7fb0cb0 --- /dev/null +++ b/src/model/bundle/policybundle.h @@ -0,0 +1,55 @@ +/*********************************************************************************************************************** +** +** Copyright (C) 2021 BaseALT Ltd. +** +** 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 2 +** 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, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +** +***********************************************************************************************************************/ + +#ifndef GPUI_POLICYBUNDLE_H +#define GPUI_POLICYBUNDLE_H + +#include "../model.h" +#include "policytreemodel.h" + +#include +#include + +class QFileInfo; + +namespace model +{ + namespace bundle + { + class ILogger; + + class GPUI_MODEL_EXPORT PolicyBundle + { + public: + PolicyBundle(const ILogger& logger); + + std::shared_ptr loadFolder(const std::string& path, const std::string& language, + const std::string& fallbackLanguage); + + private: + bool loadAdmxAndAdml(const QFileInfo &admxFileName, const std::string& language, + const std::string& fallbackLanguage); + + void logError(const std::string& error); + }; + } +} + +#endif // GPUI_POLICYBUNDLE_H diff --git a/src/model/bundle/policytreemodel.h b/src/model/bundle/policytreemodel.h new file mode 100644 index 0000000..45a06a2 --- /dev/null +++ b/src/model/bundle/policytreemodel.h @@ -0,0 +1,36 @@ +/*********************************************************************************************************************** +** +** Copyright (C) 2021 BaseALT Ltd. +** +** 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 2 +** 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, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +** +***********************************************************************************************************************/ + +#ifndef GPUI_POLICYTREEMODEL_H +#define GPUI_POLICYTREEMODEL_H + +#include "../model.h" + +namespace model +{ + namespace bundle + { + class GPUI_MODEL_EXPORT PolicyTreeModel + { + }; + } +} + +#endif // GPUI_POLICYTREEMODEL_H diff --git a/src/model/bundle/policytreemodelitem.h b/src/model/bundle/policytreemodelitem.h new file mode 100644 index 0000000..303a8a2 --- /dev/null +++ b/src/model/bundle/policytreemodelitem.h @@ -0,0 +1,36 @@ +/*********************************************************************************************************************** +** +** Copyright (C) 2021 BaseALT Ltd. +** +** 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 2 +** 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, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +** +***********************************************************************************************************************/ + +#ifndef GPUI_POLICYTREEMODELITEM_H +#define GPUI_POLICYTREEMODELITEM_H + +#include "../model.h" + +namespace model +{ + namespace bundle + { + class GPUI_MODEL_EXPORT PolicyTreeModelItem + { + }; + } +} + +#endif // GPUI_POLICYTREEMODELITEM_H