feat: add policy bundle interface

- add admx policy bundle interface
- add templates for policy model and policy tree item
This commit is contained in:
august-alt 2021-04-10 15:46:36 +04:00
parent 3c355d7159
commit 412ac4e3a9
5 changed files with 203 additions and 2 deletions

View File

@ -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)

View File

@ -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 <QDir>
namespace model {
namespace bundle {
PolicyBundle::PolicyBundle(const ILogger& logger)
{
Q_UNUSED(logger);
}
std::shared_ptr<PolicyTreeModel> 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<PolicyTreeModel>(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.
}
}
}

View File

@ -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 <memory>
#include <string>
class QFileInfo;
namespace model
{
namespace bundle
{
class ILogger;
class GPUI_MODEL_EXPORT PolicyBundle
{
public:
PolicyBundle(const ILogger& logger);
std::shared_ptr<PolicyTreeModel> 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

View File

@ -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

View File

@ -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