Compare commits

...

575 Commits

Author SHA1 Message Date
590fd624a4
style: adding QT .clang-format (#66) 2024-10-12 21:49:11 +04:00
august-alt
0fcf89a56e chore: update vesion in spec file 2024-10-11 06:33:43 +04:00
3d461644fa
fix: uncorrect work of isSpecialValueName (#84) 2024-10-10 20:41:25 +04:00
august-alt
a4e3418887 chore: update vesion in spec file 2024-10-04 14:20:16 +04:00
f9f3a89a19
fix: ListBox empty valuePrefix and additive attributes (#83)
* fix: add optional behaviour to `valuePrefix` of `PolicyListElement`

* fix: add missing `additive` behaviour to `writeListIntoRegistry`
2024-10-04 14:11:01 +04:00
august-alt
05e9d713c1 chore: update vesion in spec file 2024-09-16 14:48:42 +04:00
august-alt
880379fe12 feat: add ascii ini plugin 2024-09-16 13:51:16 +04:00
august-alt
1ed9bc7307 chore: update vesion in spec file 2024-09-13 16:14:32 +04:00
august-alt
2bd46f72e7 fix: fix path on remote smb server for comments 2024-09-13 16:12:44 +04:00
august-alt
989db5a752 fix: fix format of the policy string in main window 2024-09-13 16:08:46 +04:00
august-alt
9c316a77f8 chore: update vesion in spec file 2024-09-13 10:17:27 +04:00
august-alt
feed81b903 fix: policy name in scripts dialog 2024-09-13 10:03:27 +04:00
august-alt
876c340a48 chore: update vesion in spec file 2024-09-02 13:38:19 +04:00
august-alt
4664941773 fix: change policy version on each update 2024-09-02 13:23:09 +04:00
august-alt
d6cc694ca8 chore: update vesion in spec file 2024-08-28 15:37:39 +04:00
august-alt
54f76af358 fix: add smb support for comments 2024-08-28 15:28:43 +04:00
august-alt
c997774b35 chore: update vesion in spec file 2024-08-20 14:13:33 +04:00
Ravenwolve
024d757f97
fix: fix description in the script settings window. (#78)
* wip: setText for logonLabel

* wip: add translation for "Script" and "for"

* wip: adding `isUserScripts` field to `ScriptsDialog`

* wip: add `isUserScripts` to `setItem` functions arguments

* wip: remove `setText` from `ScriptsWidget` constructor

* wip: add `setText` to `setItem` of `ScriptsWidget` and `ScriptsPowerShellWidget`

* wip: update translation

* wip: add `gitPolicyName` method for `gpui::MainWindow`

* wip: add mainWindow field to `ScriptsSnapInPrivate`

* wip: remove `logonLabel` rewriting

* wip: add `setDescription` method to rewrite `logonLabel` text with names of script and policy

* wip: update translation

* chore: change "Default Domain Policy" to "Local Group Policy"  in scriptsdialog
2024-08-20 13:29:41 +04:00
ecbc1cbbc3
fix: fix url list based policies (#77)
* wip: add loading, writing and clean-up functions

* wip: checking for empty data in the ListBox when writing.

* wip: set `"**delvals"` value on write ListBox with non-explicit value

* wip: add verify for valuePrefix and explicitValue (they cannot be announced at the same time)

* wip: the read/write/clean code has been replaced with appropriate functions

* fix: invalid valueName/data writing

* fix: compare

* style: `m_source` -> `source`

* style: use `std::remove_if` instead of for

* fix: `AbstractRegistrySource` and `PolRegistrySource`

* fix: the prefix was ignored in `loadListFromRegistry`

* fix: get ValueName list without special records

* wip: refactor `cleanUpListInRegistry` function

* wip: small refactor `writeListIntoRegistry` function

* fix: remove case-insensitive compare

* style: `markValueNamesInKeyForDeletion` -> `markKeyForDeletion`

* fix: value may be empty in case non-explicit value name

* fix: do nothing on empty `valueList`

don't write `"**delvals."`, if nothing to delete.

* fix: check invalid combo before return in case of empty `valueList`

* style: remove unnecessary else

* chore: there is no situation with `return false`

* style: remove unnecessary `return`
2024-08-16 16:16:34 +04:00
11e8095348
fix: fix order of instructions in .pol files (#80)
* fix: rewrite `PolicyTree` type

* fix: rewrite parser to work with new `PolicyTree`

* fix: rewrite polformat to work with new `PolicyTree`

* fix: update test

* fix: incorect `operator==`

* style: remove unnecessary `get()`
2024-08-14 13:43:53 +04:00
e9275cca3a
fix: fix endianness in pol parser tests (#81)
* fix: make test cross-platform

* chore: add `PRegParser` header test (endianness)

* fix: header incorrect endianness
2024-08-14 13:42:21 +04:00
august-alt
6746815394 fix: correct comment save in empty widgets 2024-08-12 18:43:07 +04:00
572b48b43a
fix: make incorrectly saved or displayed comment values correct. (#72)
* fix: comment translation saving/loading paths

* fix: comment translation reload on language change

* wip: remove `cmtl` in `CommentsModel::save` (write to `cmtx`)

* fix: remove `toLower` from folder name
2024-08-12 17:58:49 +04:00
c60dd637d0
fix: use uint64_t instead char[8] in header buffer and valid_header. (#76) 2024-08-09 13:38:29 +04:00
d8d8515b83
fix: cast to char* instead of cast from char* (#74) 2024-08-09 13:37:57 +04:00
august-alt
1c941347f6 chore: update vesion in spec file 2024-08-06 15:16:33 +04:00
3bc4a1abd8
fix: temporary disable validation (#71) 2024-08-06 14:52:34 +04:00
august-alt
721f5f764f chore: update vesion in spec file 2024-08-06 13:01:28 +04:00
361155f763
wip: rewrite pol file serializator/deserializator (#68)
* wip: adding ragel file `pol.rl`

* wip: init cmake

* feat: update cmake files

* fead: add empty `parser.h`

* feat: add ragel to dockerfile

* wip: `libparsepol` adding

* fix: remove unnecessary `std::move`

* chore: remove ragel from docker

* chore: remove unnecessary comments

* chore: splitting tests into different methods

* chore: use `qDebug`/`qWarning`/`qCritical` instead of `std::cout`/`std::cerr`

* chore: use `QCOMPARE` instead of `std::runtime_error`/`assert` in tests

* chore: improve test for `QTest`

* fix: `BE QWORD` -> `LE QWORD`

* fix: allow multiply value with same `keyPath` and `valueName`

* chore: replace preprocessor macros with functions

* style: adding a line between functions

* chroe: small changes

style: small fix code format
wip: use one `uint64_t` variable instead of two `uint32_t` to comparison
fix: adding `Keypath` `Valuename` and type validation into writer

* chore: separate LE and BE tests

* chore: throw exception on `REG_NONE` and invalid iconv descriptor

* style: remove `./` from includes

* style: rename some functions

`bufferToString` -> `readStringFromBuffer`, `stringToBuffer` -> `writeStringToBuffer`,
`bufferToStrings` -> `readStringsFromBuffer`,
`stringsToBuffer` -> `writeStringsFromBuffer`,
`bufferToVector` -> `readVectorFromBuffer`,
`vectorToBuffer` -> `writeVectorToBuffer`,

* chore: minimize `getType`

* chore: rename `bufferToIntegral` -> `readIntegralFromBuffer`, `integralToBuffer` -> `writeIntegralToBuffer`

* chore: add new constants and use it insted of `reinterpret_cast<iconv_t>(-1)` and `reinterpret_cast<size_t>(-1)`

* chore: remove missing `./`

* chore: add missing include

* fix: rename `LittleEngian` -> `LittleEndian`

* fix: removing unnecessary PolicyBody

* chore: make `PRegParser` final and make all methods  non-virtual

* chore: remove unnecessary include

* style: rename iconv descriptors

* style: fix style
2024-08-05 15:56:14 +04:00
703563ff7b
fix: attempt to open a CMTL file in another directory (#70) 2024-08-02 15:32:02 +04:00
47a38be21a
fix: The policy options "file search service" are not working correctly (#64)
* wip: adding `BooleanValue`

* wip: adding `BooleanList` to `PolicyBoolElement`

* wip: formatting with QT `.clang-format`

* wip: improve BooleanValue with `union` for fields and cctor mctor

* wip: adding long decimal

* wip: adding some methods and small refactor

* wip: extend `XsdBooleanElementAdapter`

* wip: adding trueList/falseList support `PresentationBuilderPrivate`

* wip: fix constructors

* wip: fix adding return statement to `XsdListToAdmxBooleanList`

* fix: refactoring the code for the plugin architecture

* fix: removing unnecessary return

* style: removing unnecessary \n

* fix: write `trueValue`/`falseValue` into `trueList`/`falseList` in Admx `BooleanValue`

* wip: rearranging fields in `BooleanValue`

* fix: code refactoring with adding normal support `trueValue`/`falseValue` and `trueList`/`falseList`
2024-07-25 12:52:37 +04:00
august-alt
ef3db641f3 feat: add ragel to Dockerfile 2024-07-24 17:19:49 +04:00
9cdd285a42
feat: set c++ version to c++-17 (#67) 2024-07-24 09:43:33 +04:00
3e30fc6a15
feat: adding vscode settings folder to .gitignore (#65) 2024-07-18 23:36:00 +04:00
august-alt
c21ab68372 chore: update vesion in spec file 2024-06-14 11:33:24 +04:00
august-alt
bd1640f21d feat: load and save gpt.ini 2024-06-12 02:02:10 +04:00
august-alt
7a078218a8 fix: fix ini file format in gptiniutils 2024-06-12 02:01:38 +04:00
august-alt
b79b101a43 fix: fix version in gpt.ini file 2024-06-12 02:00:54 +04:00
august-alt
7b78be2ea0 chore: refactor ini format 2024-06-11 03:19:02 +04:00
august-alt
4af5d15a18 feat: add gpt ini util 2024-06-11 03:06:36 +04:00
august-alt
c5da19c2d4 chore: update vesion in spec file 2024-04-01 15:06:53 +04:00
august-alt
71cd6973e6 fix: fix memory leak in ini plugin 2024-04-01 14:58:32 +04:00
august-alt
3f13d0608c fix: fix attributes group box size 2024-03-25 01:28:40 +04:00
august-alt
b0b170a9c4 fix: fix issue #47727 2024-03-25 00:32:16 +04:00
august-alt
7a667924d6 chore: update vesion in spec file 2024-03-15 13:45:36 +04:00
august-alt
b2f2b02e40 fix: fix link with libsmbclient 2024-03-15 13:24:54 +04:00
august-alt
c651dc0eb8 feat: remove samba parts from project 2024-03-15 13:24:18 +04:00
august-alt
116da00491 chore: update vesion in spec file 2024-03-06 23:56:08 +04:00
august-alt
37ef0bc2a5 feat: add translations to selectvariabledialog 2024-03-05 16:55:29 +04:00
august-alt
9ea7f354c9 feat: add doubleclick to selectvariabledialog 2024-03-05 16:23:40 +04:00
august-alt
ea0ee4c566 feat: add shortcutlineedit to driveswidget 2024-03-05 16:16:18 +04:00
august-alt
43d4a9214a feat: add shortcutlineedit to folderswidget 2024-03-05 16:13:42 +04:00
august-alt
2f54d4955a feat: add shortcutlineedit to iniwidget 2024-03-05 16:11:10 +04:00
august-alt
9d49a58cc2 feat: add shortcutlineedit to registrywidget 2024-03-05 16:08:51 +04:00
august-alt
bbaf373dda feat: add shortcutlineedit to shareswidget 2024-03-05 16:08:15 +04:00
august-alt
572badcbcf feat: add shortcutlineedit to shortcutwidget 2024-03-05 16:07:24 +04:00
august-alt
7474072669 feat: add shortcutlineedit to variableswidget 2024-03-05 16:06:01 +04:00
august-alt
7d9ecaf9b3 feat: add shortcutlineedit to fileswidget 2024-03-05 16:02:58 +04:00
august-alt
a57c1c9904 feat: add constructor to shortcutlineedit 2024-03-05 16:01:55 +04:00
august-alt
3f8a21d360 feat: add shortcutlineedit 2024-03-05 15:52:34 +04:00
august-alt
0e57883d1d chore: remove addshortcut method from selectvariabledialog 2024-03-05 15:51:46 +04:00
august-alt
e7655efb15 feat: add select variable dialog 2024-03-05 00:01:10 +04:00
august-alt
cb6b00f180 wip: add select variable widget 2024-03-04 12:03:38 +04:00
august-alt
e6794612de chore: update vesion in spec file 2024-02-29 11:58:03 +04:00
august-alt
a33bb38d00 Merge branch 'bugfix_#49098' 2024-02-29 11:49:17 +04:00
august-alt
786bc372b1 feat: add 'edit item' entry to preferences context menu 2024-02-27 18:06:59 +04:00
august-alt
dd4094dbd4 fix: reorder widget elements to match file order 2024-02-26 18:41:23 +04:00
august-alt
f20d43a231 fix: replace path with name in script dialog 2023-12-26 12:40:08 +04:00
august-alt
512f19c4ec chore: update vesion in spec file 2023-12-25 18:36:00 +04:00
august-alt
ea653c4013 fix: fix scripts ui 2023-12-25 18:32:59 +04:00
august-alt
d489520d30 fix: fix creation of scripts folders 2023-12-25 18:29:47 +04:00
august-alt
2ce8fac778 chore: update vesion in spec file 2023-10-13 18:13:31 +04:00
august-alt
6c53026c3c fix: fix ldap guid path 2023-10-13 17:47:32 +04:00
august-alt
50d03e98a2 chore: update vesion in spec file 2023-10-13 16:32:34 +04:00
august-alt
f8a0cf1a12 feat: implement extension setting 2023-10-13 16:30:37 +04:00
august-alt
29541939a2 feat: fix both class policies 2023-10-10 14:37:18 +04:00
august-alt
270732c429 chore: update vesion in spec file 2023-10-09 15:57:27 +04:00
august-alt
28a9ba2156 feat: emergency fix for invalid pol files 2023-10-09 15:56:51 +04:00
august-alt
fcc0e47f9c chore: update vesion in spec file 2023-10-05 13:39:56 +04:00
august-alt
0d75f8927f fix: fix tmp permissions in dockerfile 2023-10-04 14:37:40 +04:00
august-alt
ec545987a2 fix: fix issue #47553 2023-09-22 16:03:06 +04:00
august-alt
7c42f9b19e fix: add section name to script folder path in scripts plugin 2023-09-18 13:57:20 +04:00
august-alt
f23b5f905a feat: update desktop files 2023-09-05 17:24:53 +04:00
august-alt
004792536d chore: update vesion in spec file 2023-09-04 15:43:12 +04:00
august-alt
65444d0218 fix: fix issue #47437 - add language list translation 2023-09-04 15:38:47 +04:00
august-alt
5e06fff5cc fix!: temporary remove browse button from add scripts widget 2023-09-04 15:12:07 +04:00
august-alt
d0e9ca45c7 fix: fix issue #109650 - improve translation 2023-09-04 15:04:37 +04:00
august-alt
101115b8e8 fix: fix script file encoding 2023-09-04 14:38:22 +04:00
august-alt
0cb3eb7412 chore: update vesion in spec file 2023-09-01 13:40:47 +04:00
august-alt
22667dab24 fix: fix issue #47137 2023-09-01 13:38:17 +04:00
august-alt
542cc0b420 chore: refactor logging in plugins 2023-09-01 13:27:57 +04:00
august-alt
6c54698876 fix: remove perror flag from syslog logger 2023-09-01 13:27:36 +04:00
Michael Chernigin
a9bb55ebc5
docs: add logger options to man (#61) 2023-08-31 17:25:54 +04:00
Michael Chernigin
361d3a0944
docs: logger class doxygen docs (#60)
* docs: logger doxygen docs

* fix: docs typos
2023-08-29 18:42:07 +04:00
august-alt
915cd6a68e fix: fix sisyphus build 2023-08-25 15:12:45 +04:00
august-alt
cc6efaa434 fix: fix sisyphus build 2023-08-25 14:53:23 +04:00
Michael Chernigin
36da75f293
feat: set logger levels from cli (#59)
* feat: set logger levels from cli

* feat: add default log levels

* feat: translations for logger cli options

* refactor: extract handleLoggerOption into method

* refactor: make both showHelp and showVersion exit
2023-08-25 14:29:25 +04:00
Michael Chernigin
07b9b3b5a4
feat: logger (#58)
* feat: implementation of syslog logger

* feat: implementation of file logger

* feat: show time for each logged message in file and console loggers

* refactor: more convenient log masks

* refactor: move logger files into its own directory inside core

* chore: changed all qt logs to use new logger

* chore: remove unnecessery changes

* fix: creating log file in FileLogger

* refactor: refactor logger stream to have private class

* chore: remove unnecessery logs in main

* feat: make logger thread safe

* chore: get back to qt logger

* feat: enable qt-logger

* feat: logger class

* refactor: rename abstractlogger.[ch] into logger.[ch]

* chore: remove now unneeded implementation of logger stream

* chore: remove unneeded getInstance in logger manager

* refactor: use qt's log level instead

* refactor: switch between msgType instead of having a function for each

* refactor: prelude.h to include everything needed for logger
2023-08-22 17:00:12 +04:00
Michael Chernigin
ac294b87e9
ci: build and test using clang (#57)
* chore: add llvm-common to build container

* ci: run tests also on clang

* ci: run ci on all branches

* ci: fix if for clang

* fix: change package to llvm15.0

* chore: fix clang warning about assignment inside if
2023-08-21 15:59:25 +04:00
august-alt
5bd75968c8 feat: add translations for path and arguments 2023-08-07 13:43:21 +04:00
Michael Chernigin
574e7bbe48
fix: script dialog (#51)
* refactor: refactor addscriptwidget so it does not create empty item on Add

* refactor: remove check for rootItem and at this point unused findRoot function

* refactor: rename Scripts Parameters to Script Arguments in ui files

* feat: validate script before adding and notify if script path is empty

* refactor: remove not needed delegate and mapper objects from base script widget

* refactor: cleanup ui of scripts widget

* fix: fix typo in translation

* fix: open scripts directory on smb

* revert: "refactor: cleanup ui of scripts widget"

This reverts commit 28a954d9e7f9a32e8345dd41606aec6e74f345e6.

* chore: don't change formatting in scriptssnapinprivate.cpp

* fix: restrict how big script dialog can be
2023-08-04 16:48:27 +04:00
august-alt
47d8c78834
Revert "fix: fix show files button in script dialog during smb connection" (#50)
This reverts commit 742e30b6a438c3667a29e07dc99352545639c299.
2023-08-04 16:31:10 +04:00
Michael Chernigin
742e30b6a4
fix: fix show files button in script dialog during smb connection
* refactor: refactor addscriptwidget so it does not create empty item on Add

* refactor: remove check for rootItem and at this point unused findRoot function

* refactor: rename Scripts Parameters to Script Arguments in ui files

* feat: validate script before adding and notify if script path is empty

* refactor: remove not needed delegate and mapper objects from base script widget

* refactor: cleanup ui of scripts widget

* fix: fix typo in translation

* fix: open scripts directory on smb
2023-08-03 19:07:46 +04:00
Michael Chernigin
0dccea4c98
fix: remove certain pipeline elements from execution on pull request ci (#46)
* fix: don't publish container and artifacts on pull request

* fix: don't depend on gpui-build-container in other jobs if pull request

* chore: try to move conditions inside jobs

* chore: try to move condition inside each step
2023-07-31 13:57:39 +04:00
august-alt
97e22c75b5 chore: update vesion in spec file 2023-07-21 17:38:17 +04:00
Michael Chernigin
6c9d4993c3
feat: improve filter dialog (#45)
* feat: implement 'and' and 'or' elements of definitions

* fix: add product adapter to admxformat

* feat: add comments to policy bundle

* feat: update debug output

* fix!: fix hasher-useradd usage

* feat: filter dialog shows available products tree

* feat: recursively select children

* feat: allow to resize filter dialog

* chore: uncheck parent on child uncheck

* fix: get filter returns only leafs and uncheck parent on item uncheck

* chore [wip]: get both name and display name on platforms in filter

* chore: provide supported on defenitions in filter

* chore: update of filter logic: still need to figure out way to find index in a platform tree

* fix: fix keyword filter

* fix: supported on field in policy interface

* feat: find actual index in a tree

* fix: correct supported on display text in policy view

* fix: fix always passing filter ie

* chore: speed up filterPatform by caching already found platforms in a tree

* refactor: refactor building cache

* fix: fix filter dialog translating on language change in runtime

* chore: make translations of keyword search options clear

* chore: close dialog when main window closes

* refactor: move getPlatformIndex into PlatformModel

* fix: fix segfault on language change after applying platform filters by rebuilding cache

* Revert "chore: close dialog when main window closes"

This reverts commit 2c428b004dea7e77e3c8da722e8eaaf2a7d01402.

* fix: clean all filters when language changes

* refactor: rename retranslateMenuItems to setMenuItemNames

* fix: add qstring hash and missing header

* fix: add qstring hash only if QT version is below 5.14

* feat: implement partially checked check boxes in platform tree

---------

Co-authored-by: august-alt <77973983+august-alt@users.noreply.github.com>
2023-07-21 17:22:04 +04:00
august-alt
0638908843 chore: update vesion in spec file 2023-07-19 16:58:46 +04:00
august-alt
59944735a1
fix: fix multiple errors in scripts implementation (#44)
Following changes were made:
- fix: add sections to scripts
- fix: fix scripts display
- fix: fix logic of scripts loading
- fix: fix no section crash
- fix: scripts plugin: change ini files path and create default dirs
- fix: create folder for scripts
- fix: improve debug of genericwriter
- fix: fix add script widget navigation order
- fix: disable edit triggers in script widget
- fix: fix scripts category in scriptssnapinprivate.cpp
- feat: add power shell script order entries to combobox
- feat: set format to be utf16le in ini files
- feat: disable order widget
- fix: fix conversion to wide characters in iniformat
- chore: refactor io generic writer
2023-07-19 16:54:40 +04:00
august-alt
69aaf409b5 chore: update vesion in spec file 2023-07-14 11:36:50 +04:00
august-alt
68e603d4c7
fix: fix comment file name (#43)
Following fixes were added:
- Adjust localized comments.
- Fix comment file name.
- Fix cmtx schema to support proper revision, version and minRequiredVersion.
2023-07-14 11:33:28 +04:00
august-alt
82f40833c1 chore: update vesion in spec file 2023-07-13 17:46:25 +04:00
august-alt
99caf792ff
feat: create comments plugin (#41)
Following actions were taken:
-feat: add cmtx plugin format
-feat: add cmtl plugin format
-feat: add comments plugin
-feat: add xsdcommentsadapter
-fix: fix spec file
-feat: add policy comment file
-fix: fix cmtx.xsd schema
-feat: add policy namespaces
-feat: add comment resources file implementation
-feat: implement cmtl format
-fix: fix cmtl plugin
-feat: implement adater for cmtl file
-chore: move headers to model folder
-feat: add bulk of comment snap-in
-chore: move comments model to administrative templates plugin
-feat: add comments model
-fix: fix spec file
-feat: implement comment loading
-fix: implement policy search
-feat: implement schema adapter
-feat: implement policy namespace parsing
-feat: started to implement comment saving
-feat: unify interface of comment files
-fix: fix null pointer
-feat: update save procedure
-feat: add namespace definition
-fix: fix comment text and namespace value
-fix: append namespaces
-fix: fix resource names
-fix: fix namespace model
-fix: fix namespace indices
-fix: fix addition of comments to model
-fix: prevent save of empty comments
2023-07-13 15:47:28 +04:00
august-alt
b56f3b2b6c feat: update .gitignore 2023-06-29 15:33:40 +04:00
august-alt
f0c998f4f9 feat: remove auto generated files 2023-06-29 15:33:40 +04:00
august-alt
f8324b0c75 chore: refactor preferences cmakelists.txt to use xsdutils 2023-06-29 15:16:27 +04:00
august-alt
85d45fe0d8 feat: add cmtx schema 2023-06-29 15:09:52 +04:00
august-alt
770b326d12 feat: add cmtl schema 2023-06-29 15:09:07 +04:00
august-alt
f8df2ad964 feat: add xsd utils for libraries 2023-06-29 15:08:40 +04:00
august-alt
517fdf5040 fix!: fix hasher-useradd usage 2023-06-28 17:46:14 +04:00
august-alt
8037f35de8 build!: remove codeql workflow 2023-06-28 16:59:47 +04:00
august-alt
c5a3b095d4 fix!: replace numbers with constants for parent and current uuid roles 2023-06-27 16:55:54 +04:00
august-alt
f13ddd33ad chore: remove unused element from template filter ui 2023-06-26 12:55:53 +04:00
Michael Chernigin
9a58d94c35
chore: refactor filter model and dialog (#40)
* refactor: refactoring of filter model

* refactor: more refactoring of filter model diaglog

* chore: hide inactive managed and commented options

* fix: one less memory leak

* chore: added paranthesis in logical expr
2023-06-26 12:27:21 +04:00
august-alt
8cef289f46 fix!: add #include <cstdint> to pregdata.h 2023-06-21 15:20:31 +04:00
august-alt
67613c6047 chore: update vesion in spec file 2023-06-21 15:11:18 +04:00
august-alt
6ca0b1e5d7 fix: fix filter and platform models update 2023-06-21 14:37:03 +04:00
august-alt
fec1ceb62f feat: add check for compiler flag support 2023-06-20 19:39:49 +04:00
august-alt
9db5f1fea5 feat!: switch to cmake 3.14 or higher 2023-06-20 19:39:23 +04:00
august-alt
df0b86ac75 chore: update vesion in spec file 2023-06-20 19:15:23 +04:00
august-alt
1908488b00
feat: implement filter dialog for administrative templates (#39)
* feat: add template filter

* feat: implement filter

* chore: add policyelement includes

* chore: remove template filters form mainwindow

* feat: add platform model

* chore: refactor template filter dialog

* chore: refactor administrative template snapin

* feat: add translation for filters

* fix: fix tests
2023-06-20 19:11:59 +04:00
Michael Chernigin
1d36ccc503
feat: improve continuous integration process (#36)
Description:
    Add docker buildx to create containers.
    Resolve problems with CodeQL.
    Update CI pipeline and separate main workflow into pieces. Add build, build container and test workflows.

History:
* Test build and push action
* Update CodeQL analysis from v1 to v2
* Add dependencies
* Use Ninja instead of GNU Make
* Switch back to GNU Make & fix main CI
* Fix tabs in main.yml
* Add build arguments
* Change mode to github actions
* Add run stage
* Push to ghcr
* Bump up of action versions
* Run container
* Use same image in test
* Separate workflow for build docker image
* Try another name for action
* All on push
* Proper names
* Correct order
* Add sudo in test
* No sudo
* Add ctest as dependency in Dockerfile and pull image first in build
* Main workflow to run others as jobs
* Fix order
* Checkout to code in build
* Checkout in tests
* Run CodeQL in same container
* Speed up CodeQL build by using Make directly
* Mount RPM directory
* Test on i386 also
* Removed unused parameters and pull specific platform in build
* Set target for gear-rpm
* Back to 2 images
* Set permissions for packages
* Get uid and gid
* Remove QEMU
* Try to utilize mode caching by having separate cache between branches and architectures
* Try not to use actions
2023-06-09 12:39:15 +04:00
august-alt
fc928f54c9 chore: update vesion in spec file 2023-06-07 16:53:31 +04:00
august-alt
107b270702 Merge branch 'namespace_fixup' 2023-06-07 16:49:22 +04:00
august-alt
a5c5c8c9f7 fix!: fix list saving 2023-06-07 03:40:00 +04:00
august-alt
10671172f7 fix: fix namespaces 2023-05-30 14:40:35 +04:00
Michael Chernigin
1a6bf7bdbd
docs: add readme improvements (#35)
* docs: screenshot and build instruction in readme

* fix: screenshot of english version
2023-05-29 11:27:09 +04:00
august-alt
97f3f0aef8
fix!: fix ability to write boolean policies with just valueNames (#34)
* wip: add naive impementation of valueName only policy

* refactor: cleanup for implementation valueName only policies (#33)

---------

Co-authored-by: Michael Chernigin <59616661+mchernigin@users.noreply.github.com>
2023-05-25 20:31:47 +04:00
august-alt
2a3de65619 chore: update vesion in spec file 2023-05-19 15:00:47 +04:00
august-alt
4607d7c4fa fix: fix utility launch without a path 2023-04-18 12:36:49 +04:00
AlexSP0
e448cc35c4
fix: added type checking when setting a value 2023-04-13 15:49:26 +04:00
august-alt
a83ff03832 chore: update vesion in spec file 2023-04-11 18:23:20 +04:00
AlexSP0
0fb3211b76
fix: fix crash when pressing the cancel button in the script module 2023-04-11 18:13:07 +04:00
august-alt
18aa62bb7a fix: fix presentation builder test 2023-04-11 17:48:38 +04:00
august-alt
bcdcf6785f fix: add ctest 2023-04-11 17:17:50 +04:00
august-alt
d82d055935 fix: add rpm-build 2023-04-11 16:52:07 +04:00
august-alt
482669cb6c fix: update cmake config 2023-04-11 16:34:58 +04:00
august-alt
7ffdda83b5 fix: remove sudo command 2023-04-11 16:17:46 +04:00
august-alt
010763fd72 fix: run tests in container 2023-04-11 15:43:32 +04:00
august-alt
16d6b29a50 tests: add tests to ci 2023-04-11 15:16:51 +04:00
august-alt
636a6d3c7f fix: fix tests 2023-04-11 14:33:38 +04:00
AlexSP0
0ae9861008
chore: add test for TranslatorStorage 2023-04-11 14:15:20 +04:00
AlexSP0
46ab925906
fix: switch method loadTranslators from QDirIterator to QDir
There is issue with QDirIterator not loading some of translation from resource files. Switching to QDir allows us to load all of translations.
2023-04-11 13:51:02 +04:00
AlexSP0
c587a4aac9
chore: moved setErrorString to private section 2023-04-10 19:14:23 +04:00
AlexSP0
f00c4b3458
chore: refactor translations
* chore: add TranslatorStorage class

* chore: refactor TranslateStorage class

* chore: refactor loading translations in main function, MainWindow class and snapins

* chore: some small fixes

* chore: make TranslateStorage not singleton

* chore: small refactor translatestorage class
2023-04-07 15:16:47 +04:00
august-alt
4244048b59 chore: update vesion in spec file 2023-04-05 15:16:36 +04:00
august-alt
89426d98ea fix: fix issue with files without extensions in preferences 2023-04-05 15:14:01 +04:00
august-alt
a387aa9cf7 chore: update vesion in spec file 2023-03-29 17:56:11 +04:00
august-alt
974135377c fix: add backslash to the end of policy path in scripts plugin 2023-03-29 17:48:39 +04:00
august-alt
d63a987dd5 fix: fix path in scripmodelio 2023-03-29 17:41:31 +04:00
august-alt
9f54190fd5 chore: update application version 2023-03-29 17:00:18 +04:00
august-alt
bc00620def fix: select scrips tab by default 2023-03-28 16:54:52 +04:00
august-alt
737fce25f5 fix: deselect item after deleting it 2023-03-28 16:35:19 +04:00
august-alt
27d7e0e19a chore: update vesion in spec file 2023-03-27 15:36:55 +04:00
august-alt
36fccd01b3 fix: add clear button to qkeysequenceedit 2023-03-27 15:25:42 +04:00
august-alt
dd3d9e9c25 fix: fix dialog in ScriptsContentWidget
When user clicks listview item but does not change
selection in listview dialog will not be displayed.
This commit fixes issue by attaching startDialog method
to QListView::clicked this allows dialog to be shown regardless
of what item is currently selected.
2023-03-17 15:59:46 +04:00
august-alt
2ae5d38b6f fix: fix regex for ini parameter value in scriptmodelbuilder 2023-03-17 15:43:33 +04:00
august-alt
d809524132 fix: #96328, fix writing script files to smb shares 2023-03-16 17:33:07 +04:00
august-alt
b82ea3b490 fix: fix translation of scripts snap-in 2023-03-14 17:20:54 +04:00
august-alt
600861c870 fix: fix typo in folders preference 2023-03-14 16:43:09 +04:00
august-alt
cf16d5b18a chore: update vesion in spec file 2023-03-14 13:54:45 +04:00
august-alt
7030ef2eae fix: #96489, fix policy key search for lists
Due to variables been captured in lambda by reference,
search of key always ended finding key for last element.
This commit solves this issue adding capture of function
parameters by value. This makes search work as intended.
2023-03-14 13:27:10 +04:00
AlexSP0
5a225cd901
feat: add executable attribute to the fileswidget (#22) 2023-03-13 18:03:17 +04:00
august-alt
d6f0c19375 chore: switch cmake policy 0071 to new
We don't need to apply cmake to autogenerated files here,
so we switch policy to new type of behavior.
2023-03-06 20:14:20 +04:00
august-alt
c72e2ffe32 chore: update vesion in spec file 2023-03-05 20:35:05 +04:00
august-alt
9556de162d fix: replace std::regex with QRegularExpression 2023-03-05 20:32:38 +04:00
august-alt
54ab6314b0 chore: update vesion in spec file 2023-03-05 17:37:33 +04:00
august-alt
d182a8cc4c Merge branch 'scripts' 2023-03-05 17:34:52 +04:00
august-alt
f0705aede0 fix: revert adldap_config.h to initial state 2023-03-05 17:32:14 +04:00
august-alt
4d72a2f91a fix: remove erasure of double backslash in a script path 2023-02-26 20:04:13 +04:00
august-alt
5b83c5bad9 fix, chore: refactor addscriptwidget 2023-02-21 16:57:10 +04:00
august-alt
cb8ca9f6c3 fix: refactor item category 2023-02-11 22:25:30 +04:00
august-alt
2b93157be2 fix: remove unused models setup in scriptstreeproxymodel 2023-02-11 22:24:25 +04:00
Alexey Saprunov
01c140957b chore: implement browse button functionality in addscriptwidget 2023-01-27 15:51:20 +04:00
Alexey Saprunov
62b8ec57c6 fix: fixed crash when clicking up, down, delete without selecting an item in scripts dialog tabs 2023-01-27 14:59:05 +04:00
Alexey Saprunov
038aa640c0 chore: implement browse button 2023-01-27 14:47:21 +04:00
Alexey Saprunov
f4e65035a1 fix: rename basescriptswidget to basescripttabwidget 2023-01-21 12:20:54 +04:00
Alexey Saprunov
5e4f5afbe0 fix: translations in scriptstreemodel and remove comment in CMakeLists.txt 2023-01-21 11:54:23 +04:00
Alexey Saprunov
a117f176f1 chore: add translations for srciptscontentwidget 2023-01-20 12:27:26 +04:00
august-alt
c28d1bcade chore: update version in spec file 2023-01-19 15:23:55 +04:00
august-alt
4c7487dc35 chore: refactor version.h.in in core library 2023-01-18 18:00:47 +04:00
august-alt
c104378310 chore: update workflow 2023-01-18 17:35:43 +04:00
august-alt
56ce03f349 chore: update workflow 2023-01-18 17:22:37 +04:00
august-alt
eb4316e7da chore: refactor model type 2023-01-18 16:31:00 +04:00
Alexey Saprunov
6e2a50de2d fix: fix scripts translation and remove comments in scriptsitem.h 2023-01-18 15:28:40 +04:00
august-alt
7f74dc33ed fix, wip: set default user context flag to true in user policies 2023-01-18 12:35:21 +04:00
august-alt
f52c468197 fix: fix inability to input section name on delete mode in ini widget 2023-01-17 17:06:58 +04:00
Alexey Saprunov
0ca63a56d8 fix: empty parameters in addscriptswidget 2023-01-16 16:23:16 +04:00
Alexey Saprunov
378c994bf7 Merge branch 'master' into scripts 2023-01-16 16:15:21 +04:00
Alexey Saprunov
5111883b90 chore: add qstandartitem model in scriptscontentwidget 2023-01-16 14:34:23 +04:00
Alexey Saprunov
12c5599672 chore: add translates for scripts widget 2023-01-16 14:33:05 +04:00
august-alt
acd9ecb272 chore: update version in spec file 2023-01-12 16:42:39 +04:00
august-alt
47e66146ff fix: fix issue #91098, on KDE based systems 2023-01-12 16:36:56 +04:00
august-alt
6ae7afa419 fix: fix issue #91098, on KDE based systems 2023-01-12 16:25:03 +04:00
Alexey Saprunov
623848fe51 Merge branch 'master' into scripts 2023-01-12 12:41:53 +04:00
august-alt
0afe601545
Merge pull request #21 from AlexSP0/fix_race_condition_with_adinterface
fix: race condition problems with AdInterface
2023-01-10 22:45:02 +04:00
august-alt
9eebda5cb4 chore: update version in spec file 2023-01-10 17:12:37 +04:00
august-alt
874d5294d1 feat: add shortcut encoding 2023-01-10 17:09:45 +04:00
Alexey Saprunov
0aa22e6739 fix: race condition problems with AdInterface 2023-01-10 12:53:17 +04:00
august-alt
d10ea4913e fix: fix issue #91098, fix translation of qsequenceedit 2023-01-10 10:33:17 +04:00
august-alt
ee85fef4fd chore: add files for key sequence encoder 2023-01-09 17:05:03 +04:00
august-alt
c79fe9b5d2 chore: add version.h to .gitignore 2023-01-05 20:47:39 +04:00
august-alt
be6facc00f fix: add space to label in about dialog 2023-01-05 20:46:15 +04:00
august-alt
6577078948
Merge pull request #20 from AlexSP0/auto_update_version
feat: add auto update version in about dialog
2023-01-05 20:38:45 +04:00
Alexey Saprunov
686fa18c8f feat: add auto update version in about dialog 2023-01-05 20:17:20 +04:00
august-alt
425250a2df chore: update install.md 2022-12-29 17:32:07 +04:00
august-alt
605945dae9 chore: update version in spec file 2022-12-28 13:21:07 +04:00
august-alt
900b7305de fix: fix issue #75874, fix spin box 2022-12-28 13:11:41 +04:00
august-alt
aea8c2dbe1 feat!: change plugin loading mechanism 2022-12-28 11:47:57 +04:00
august-alt
3c0cbfe925 fix: fix issue #91635, fix e2k build 2022-12-28 11:43:37 +04:00
august-alt
a88076439c chore: fix code style in mainwindow.cpp 2022-12-28 11:32:18 +04:00
august-alt
c648987608 fix: add prefix for translation resources 2022-12-28 11:31:50 +04:00
august-alt
74020ccc6b chore, gitignore: add qt translation resources to .gitignore 2022-12-28 11:30:26 +04:00
august-alt
be26545745 wip: fix issue #75874, add spin boxthat mirrors behaviour of windows spinbox 2022-12-27 17:29:51 +04:00
august-alt
d0a0712d50 fix: fix save process on message box ok button signal 2022-12-27 13:13:34 +04:00
august-alt
da73bf166a fix: fix issue #91060, ok and cancel buttons now work in a message box 2022-12-27 13:00:42 +04:00
august-alt
870d2ff3b9 fix: fix issue #89621, fix typo in ini widget 2022-12-27 12:21:40 +04:00
august-alt
e82e71e462 chore: update vesion in spec file 2022-12-26 13:08:01 +04:00
august-alt
803a32ee5c chore: update translations in gui library 2022-12-25 04:05:20 +04:00
august-alt
df481efbea fix: fix issue #91312, add translation to '-n' command line option 2022-12-23 11:46:34 +04:00
august-alt
d2f03eb120 fix: fix issue #90987, fix status bar message 2022-12-23 10:38:43 +04:00
august-alt
d1a3e0f765
Merge pull request #17 from AlexSP0/fix_segmentation_error_in_the_absence_of_kerb_tickets
fix: segmentation error in the absence of kerberos tickets
2022-12-22 19:43:30 +04:00
854dc23085 fix: segmentation error in the absence of kerberos tickets 2022-12-22 18:57:45 +04:00
august-alt
49fea6c996 fix: fix issue #91237, remove sorting in table header 2022-12-22 14:33:09 +04:00
august-alt
e951a732e1 fix: fix issue #91097, fix names of hidden and archive fields in folder widget 2022-12-21 16:30:11 +04:00
august-alt
76eb93d6d3 chore: update version in spec file 2022-12-15 16:18:45 +04:00
august-alt
0b2c794d1e fix: add static_cast in presentation builder to fix e2k build 2022-12-15 15:56:39 +04:00
Alexey Saprunov
f364ccdfe1 chore: delete scriptswidgetcommonslots class and refactor basescriptswidget class 2022-12-15 15:32:35 +04:00
Alexey Saprunov
38c226cc2d Merge branch 'master' into scripts 2022-12-15 14:43:12 +04:00
august-alt
78a9bc093a chore: update spec file 2022-12-15 14:23:12 +04:00
august-alt
e06b09dc50 fix: apply patch to fix build on e2k 2022-12-15 14:21:14 +04:00
august-alt
9056c671b7 chore: update version in spec file 2022-12-09 17:51:32 +04:00
august-alt
fa48996c3f fix: fix issue #89597, improve error messaging 2022-12-09 17:41:13 +04:00
august-alt
d9a447f1e9 chore: update translations 2022-12-09 17:40:20 +04:00
august-alt
b2235289a5 fix: fix issue #88897, now widget asks to save changes 2022-12-09 17:24:02 +04:00
august-alt
2ea72f3227 fix: implement element sorting 2022-12-08 18:28:21 +04:00
august-alt
830cc8dce2 fix: fix issue #75885, dropdown elements now do not have a specific order 2022-12-08 18:05:31 +04:00
august-alt
ffa0adf908 fix: set correct resource for non existent registry.pol files 2022-12-08 14:59:57 +04:00
august-alt
47c9920534 fix: remove repeated selection of items in content widget 2022-12-08 14:46:40 +04:00
august-alt
d6152522cf fix: copy policy to copied item 2022-12-08 14:28:36 +04:00
august-alt
2e7c75801d fix: resolve enum types 2022-12-08 13:39:03 +04:00
august-alt
317eed72d8 chore: update version in spec file 2022-12-06 17:05:30 +04:00
august-alt
9dda37fdf8 fix: fix issue #89648, fix russian translation of common widget 2022-12-02 17:29:13 +04:00
august-alt
90545e20b9 fix: fix issue #89648, fix russian translation of shares widget 2022-12-02 17:24:39 +04:00
august-alt
6224f271de chore: change target type in shortcuts widget 2022-12-02 16:07:29 +04:00
august-alt
b66244ec0e fix: fix issue #89692, fix translation of shortcuts widget 2022-12-02 16:06:48 +04:00
Alexey Saprunov
8507cd2180 fix: replace strings with enum in scriptsitem 2022-12-02 10:10:10 +04:00
august-alt
df55769f5e fix: fix issue #89621, fix ini file's widget translations 2022-12-01 17:46:32 +04:00
Alexey Saprunov
f57e0bd625 fix: fix scriptscommonwidgetslots, contentwidget, itemtype, translations 2022-12-01 12:38:29 +04:00
august-alt
285c3e26f4 fix: fix issue #89561, fix russian translations in properties widget 2022-11-30 18:24:45 +04:00
august-alt
6ebb83071a fix: fix issue #89558, translate "specify full path" in shortcuts widget 2022-11-30 17:57:49 +04:00
august-alt
8e2506c809 fix: fix issue #89553, switch search to be case insensitive 2022-11-30 17:44:02 +04:00
august-alt
61e012af17 chore: update version in spec file 2022-11-30 17:06:20 +04:00
august-alt
61364b4b84 fix: remove colon from letter name in drive maps xml 2022-11-30 17:04:40 +04:00
august-alt
1a60a3f294 fix: fix issue (github) #16, remove null pointer by creating dom_sid 2022-11-30 15:05:43 +04:00
Alexey Saprunov
68ff6ed8fe fix: paths for ini files 2022-11-29 19:27:13 +04:00
Alexey Saprunov
bd5ad52005 fix: erroneous deletion in scriptstreeproxymodel 2022-11-29 19:19:36 +04:00
Alexey Saprunov
e0668d49df fix: typos in filename 2022-11-29 17:46:16 +04:00
Alexey Saprunov
3077e6cf9e fix: hardcoded itemtype 2022-11-29 17:35:00 +04:00
august-alt
d80572515f chore: update version in spec file 2022-11-29 14:25:09 +04:00
august-alt
7ac6ac1d9e fix: fix issue #88844, fix save of admx path setting 2022-11-29 13:13:49 +04:00
august-alt
b23c3bec77 fix: fix issue #88711, modify model builder of network shares to write only neccesary fields 2022-11-29 12:41:26 +04:00
Alexey Saprunov
5eedc5d9cf chore: add signal and slots to scriptsdialog to save and load data 2022-11-29 11:51:22 +04:00
august-alt
2a1a199a7b fix: fix issue #74009, remove captions in empty widget 2022-11-28 17:45:03 +04:00
Alexey Saprunov
e31675899c fix: fix scripts tree model and scripts content widget 2022-11-25 18:13:27 +04:00
august-alt
5fabded652 fix: fix issue #44378, allow empty section name in ini widget 2022-11-25 17:41:59 +04:00
august-alt
d6f7a69889 fix: fix issue #88794, tools now can open xml for drive maps. 2022-11-24 16:42:47 +04:00
august-alt
2a199fa817 fix: fix issue #88602, fix attributes for network shares 2022-11-24 16:15:25 +04:00
august-alt
689d06bb51 fix: fix russian translations for network shares widget 2022-11-24 15:01:33 +04:00
Alexey Saprunov
1b65f4ad70 chore: add translation 2022-11-24 14:12:00 +04:00
august-alt
26e6d1d112 fix: fix russian translation of environment variables string 2022-11-24 13:04:50 +04:00
august-alt
f9264fdaa2 fix: fix russian translations in drives widget 2022-11-24 13:01:12 +04:00
august-alt
fc90e275bd !chore: refactor -n command line option 2022-11-23 15:36:09 +04:00
Alexey Saprunov
3bb8acda2a fix: fix the crash when pressing add button in scripts dialog and scripts model is empty 2022-11-22 22:37:53 +04:00
Alexey Saprunov
cf901b77ca fix: fix the crash when pressing edit button and no item selected 2022-11-22 18:10:01 +04:00
august-alt
e601430ce1 fix: update spec file 2022-11-22 17:20:04 +04:00
august-alt
fb366bed62 fix: fix issue #88586, fix mapped drive russian translation 2022-11-22 16:58:03 +04:00
august-alt
48480a4075 fix: fix issue #88813, restore dependency on admx-basealt in spec file 2022-11-22 16:51:56 +04:00
august-alt
a17235d53e fix: switch to readonly access for local files in preferences 2022-11-22 16:49:13 +04:00
Alexey Saprunov
0e9f1ffa1b fix: fix the crash when pressing cancel button in scripts dialog 2022-11-22 11:42:47 +04:00
Alexey Saprunov
dfeb6cca52 chore: chooosing model for scripts dialog 2022-11-21 16:39:35 +04:00
Alexey Saprunov
e705406743 fix: fix saving ini file 2022-11-21 10:11:34 +04:00
Alexey Saprunov
b3631ee6f3 chore: run scripts dialog then selected scripts in tree view, set signal to load and save scripts 2022-11-21 08:02:26 +04:00
august-alt
de3d75daf6 fix: remove dots at the end of sentenses in common widget 2022-11-18 16:02:33 +04:00
august-alt
0c1806a5f3 fix: fix issue #88495, fix translations in environment variable widget 2022-11-18 15:54:20 +04:00
august-alt
c666d54533 fix: fix issue #88495, fix translations in environment variable widget 2022-11-18 15:52:37 +04:00
august-alt
0ec7439bbb Revert "wip: begin encoding of virtual keys for shortcuts"
This reverts commit 9dd106ccb0d0c52bde72f7afcad7438c1b5efaab.
2022-11-18 15:00:14 +04:00
august-alt
5bb056cc53 fix: remove invalid headers 2022-11-17 19:06:45 +04:00
august-alt
9dd106ccb0 wip: begin encoding of virtual keys for shortcuts 2022-11-17 18:44:25 +04:00
august-alt
f162e30770 chore: update version in spec file to 0.2.17-alt6 2022-11-16 18:55:45 +04:00
august-alt
fff597fd53 feat!: add network share and mapped drives for users and computers 2022-11-16 18:52:43 +04:00
august-alt
26e665752f chore: update version in spec file 2022-11-16 16:05:56 +04:00
august-alt
783a1440c9 Revert "fix!: remove -n option it is now replaced with policy name from ldap"
This reverts commit e7f63b7181e8152716ac31f155bf4c90d77e0afb.
2022-11-16 16:00:20 +04:00
Alexey Saprunov
9b6fcc5add chore: implement saving scripts files in required format 2022-11-16 12:14:28 +04:00
Alexey Saprunov
b0a78b4c63 fix: fix basescriptswidget, scriptswidget, scriptspowershellwidget, scriptscommonslots, modelbuilder, scriptsmodelio 2022-11-16 09:35:23 +04:00
Alexey Saprunov
0ae5a7bfea Merge branch 'master' into scripts 2022-11-16 08:52:12 +04:00
august-alt
cadd5d048f fix: set only one key sequence in shortcut widget 2022-11-15 18:57:20 +04:00
august-alt
e000044202 fix: fix xml structure for file preferences 2022-11-15 18:29:51 +04:00
august-alt
5f8c82e3d5 fix: fix issue #88226, fix folder creation 2022-11-15 18:12:22 +04:00
august-alt
f1bff99f44 fix: update names in path of objects; preferences module 2022-11-15 18:05:38 +04:00
august-alt
275ae12822 fix: fix widget state on target type change for shortcuts widget 2022-11-15 15:44:21 +04:00
august-alt
318908721a fix: fix window mode encoding in shortcuts widget 2022-11-15 13:50:24 +04:00
august-alt
fb5e640f05 fix: fix location encoding for shortcuts widget 2022-11-15 13:42:01 +04:00
august-alt
f013cdb407 wip: encode path 2022-11-14 18:35:59 +04:00
august-alt
ad20e8db2e fix: fix folders widget 2022-11-14 16:47:12 +04:00
Alexey Saprunov
deadc04ba1 Merge branch 'master' into scripts 2022-11-14 15:56:52 +04:00
august-alt
fefe8dea08 fix: show help on help action in preferences context menu 2022-11-14 12:57:51 +04:00
Alexey Saprunov
3b75a7fae4 feat: implement scripts plugin 2022-11-11 17:29:55 +04:00
august-alt
edcb547d7c chore: update spec file 2022-11-11 15:47:30 +04:00
august-alt
3d5015953d fix: fix item deselection 2022-11-11 15:45:49 +04:00
august-alt
ff91ace771 feat: hide information on preference when it is not selected 2022-11-11 15:32:25 +04:00
august-alt
acb363a231 feat: add custom tree view to show that there is no policies 2022-11-11 14:28:13 +04:00
august-alt
270cecc60a chore: update spec file 2022-11-11 12:42:08 +04:00
august-alt
2febea95dd fix: fix translations in policy tree 2022-11-11 12:32:17 +04:00
august-alt
8e362afdd6 chore: update translations in administrative templates 2022-11-11 12:19:51 +04:00
august-alt
e7f63b7181 fix!: remove -n option it is now replaced with policy name from ldap 2022-11-11 12:19:13 +04:00
august-alt
1483cd32f7 fix: fix version in main.cpp 2022-11-11 12:15:27 +04:00
august-alt
88a462d309 chore: refactor policy name display 2022-11-11 12:02:27 +04:00
august-alt
86a4354abf fix: fix crash when policy path is empty 2022-11-11 12:01:59 +04:00
august-alt
945c25454a fix: fix double context initialization 2022-11-10 18:52:38 +04:00
august-alt
038325da46 fix: fix cast-align warning 2022-11-10 18:50:42 +04:00
august-alt
93b6fb96db chore: update version in spec file 2022-11-10 18:16:47 +04:00
august-alt
44ce73e828 fix: fix memory leak in LDAPImpl 2022-11-10 18:15:23 +04:00
august-alt
8545f16a1d fix: set default focus in preferences dialog on ok button 2022-11-10 18:11:02 +04:00
august-alt
ed028ae035 fix: add support of smb protocol to preferences writer 2022-11-10 17:53:46 +04:00
august-alt
7808ced8de fix: fix issue #74208 2022-11-10 17:33:07 +04:00
august-alt
add47ed7e1 fix!: remove toSet and toList methods 2022-11-10 17:31:18 +04:00
august-alt
f31ef90447 fix: add support of smb protocol to preferences reader 2022-11-10 17:13:37 +04:00
august-alt
64cf951568 fix: try toSet in ad_config.cpp 2022-11-10 17:10:32 +04:00
august-alt
511f603997 fix: made build on p9 possible 2022-11-10 16:19:59 +04:00
august-alt
bd3d7a0d5c
Merge pull request #12 from AlexSP0/ldap_lib
feat: implement gpui-ldap library and get display name of GPO in main…
2022-11-10 16:14:58 +04:00
Alexey Saprunov
7ab9634089 chore: add comment for getDisplayNameGPO 2022-11-10 15:50:01 +04:00
Alexey Saprunov
d58bf70f02 Merge branch 'master' into ldap_lib 2022-11-10 15:48:25 +04:00
august-alt
e50445f1e1 fix: fix display role 2022-11-10 15:29:07 +04:00
Alexey Saprunov
1b49890f9a feat: implement gpui-ldap library and get display name of GPO in main window 2022-11-10 14:55:45 +04:00
august-alt
dfc48059a9 fix: restore name of root tree element 2022-11-10 14:55:09 +04:00
august-alt
1d1dbde398 docs: update man pages 2022-11-10 14:22:26 +04:00
august-alt
3b76432064 fix: translate actions 2022-11-09 19:46:25 +04:00
august-alt
7ec486a5bb feat: add save message for preferences snap-in 2022-11-09 16:43:27 +04:00
august-alt
232933d183 fix!: disable not implemented elements 2022-11-09 16:43:06 +04:00
august-alt
2075b36743 fix: add word wrap for lables in properties widget 2022-11-09 16:14:24 +04:00
august-alt
89f24f41b2 feat: add method retranslateStrings to item container interface 2022-11-09 16:10:51 +04:00
august-alt
261b748d05 fix: fix data saving on item update for preferences 2022-11-09 14:48:19 +04:00
august-alt
6c7af51291 feat: implement boolean delegate 2022-11-09 14:45:34 +04:00
august-alt
ed2630344f feat: update preferences dialog translation 2022-11-08 20:17:52 +04:00
august-alt
05aac973c6 feat: remove ok and cancel buttons form table details widget 2022-11-08 19:55:00 +04:00
august-alt
afbf8a6def chore: reorder menu element 2022-11-08 19:35:50 +04:00
august-alt
f43429fb81 fix: fix drives schema 2022-11-08 19:33:57 +04:00
august-alt
3401d48931 chore!: remove invalid actions in table details widget's menu 2022-11-08 18:34:31 +04:00
august-alt
e5e0173559 fix: fix version in about dialog 2022-11-08 17:45:09 +04:00
august-alt
bf5c3b2d27 fix: remove item on cancel in table details widget 2022-11-08 17:43:39 +04:00
august-alt
407b77c184 feat: add path validation to drives widget 2022-11-08 15:16:53 +04:00
august-alt
45e34b2f82 fix: add value validation to preferences dialog 2022-11-08 15:13:22 +04:00
august-alt
c55186fda4 wip, feat: create policy tree root element 2022-11-08 14:21:27 +04:00
august-alt
17e819a021 chore: update translation for environment variables 2022-11-07 20:05:39 +04:00
august-alt
c5bc4c500f chore: update translation for shortcuts 2022-11-07 20:05:25 +04:00
august-alt
1225a7b006 chore: update translation for network shares 2022-11-07 20:05:12 +04:00
august-alt
1807308b70 chore: update translation for registry 2022-11-07 20:04:59 +04:00
august-alt
89e793315b chore: update translation for ini files 2022-11-07 20:04:45 +04:00
august-alt
a7a7f2bd6b chore: update translation for folders 2022-11-07 20:03:25 +04:00
august-alt
4b92ed680d fix: fix russian translation 2022-11-07 19:51:08 +04:00
august-alt
602f8375f9 chore: update translation for files 2022-11-07 19:34:11 +04:00
august-alt
0e5172b641 chore: update translation in drives 2022-11-07 19:31:21 +04:00
august-alt
e20903a71c fix: fix model update for drives in drives model builder 2022-11-07 18:28:35 +04:00
august-alt
0c8de12b61 feat: add drives support 2022-11-07 18:25:35 +04:00
august-alt
1c5fda6c16 feat: implement folder creation for administrative templates snap-in 2022-11-07 17:00:03 +04:00
august-alt
0435370b1e fix: fix directories creation in preferences snap-in 2022-11-07 16:56:23 +04:00
august-alt
e07ed2f93d fix: create top preferences folder 2022-11-07 16:37:25 +04:00
august-alt
59091f4e38 feat: add directory creation for preferences 2022-11-07 16:10:11 +04:00
august-alt
5451c29442 fix: fix date in spec file 2022-11-03 17:11:18 +04:00
august-alt
dc3e667e2f Merge branch 'master' into merge_preferences 2022-11-03 17:00:04 +04:00
4d8dcfb0b3 feat: implement gpui-ldap library and get display name of GPO in main window 2022-11-03 16:11:55 +04:00
august-alt
3d9ebb93bb fix: fix translations 2022-11-03 15:00:46 +04:00
august-alt
16f168a4af chore: update programming interface of preferences snap-in 2022-11-03 13:26:58 +04:00
august-alt
4f3466bdc3 feat: implement settings restoration, admx loading 2022-11-03 13:26:27 +04:00
august-alt
59a8f9d64f !feat: add main window to snap-in interface 2022-11-03 13:22:59 +04:00
august-alt
4bb2e4db04 chore: update version in spec file 2022-11-03 12:31:59 +04:00
august-alt
e6489c0597 chore, build: update build process, revert to using rpm-build 2022-11-03 12:12:41 +04:00
august-alt
01ec337039 fix: remove control panel settings from model 2022-11-03 10:21:57 +04:00
august-alt
a4feec6b62 fix: update tree model translation for preferences snap-in 2022-11-02 18:26:28 +04:00
august-alt
f3f0d78102 chore: update translations 2022-11-02 18:13:27 +04:00
august-alt
f68246190f fix: rename translation files to remove name collision 2022-11-02 18:11:29 +04:00
august-alt
deb384c9bb feat: add model type 2022-11-02 18:06:51 +04:00
august-alt
5702d4c6e4 fix: fix language string in preferences snap-in 2022-11-02 17:46:21 +04:00
august-alt
88f2537bad chore: refactor administrative templates 2022-11-02 15:14:35 +04:00
august-alt
dbef2f44ad feat: implement translation for administrative templates 2022-11-02 15:13:34 +04:00
august-alt
3c203b20cb chore: update translation in preferences plugin 2022-11-02 14:37:53 +04:00
august-alt
f4a9502b8c chore: update administrative templates translation 2022-11-02 13:40:36 +04:00
august-alt
117868d273 feat: implement widget creation 2022-11-01 17:54:56 +04:00
august-alt
9bf954c494 wip: update item creation 2022-11-01 16:56:00 +04:00
august-alt
f539646075 wip: refactor model creation 2022-11-01 16:40:13 +04:00
august-alt
4734592b46 wip: update model items ids 2022-11-01 14:04:52 +04:00
august-alt
d8f283dbd3 feat: update administrative templates snap-in 2022-10-31 15:22:42 +04:00
august-alt
e952f1f8a0 feat: update administrative templates proxy model to support policy sources 2022-10-31 15:21:42 +04:00
august-alt
26bde93a05 feat: implement translation for administrative templates 2022-10-31 15:20:00 +04:00
august-alt
b2e32606ff feat: finish implementation of administrative templates widget 2022-10-31 15:19:07 +04:00
august-alt
8152af72fc wip: refactor administrative templates widget 2022-10-31 11:39:36 +04:00
august-alt
a259e03453 wip: refactor content widget 2022-10-29 16:00:32 +04:00
august-alt
bc995661a8 fix: clean snap-in memory 2022-10-28 05:28:36 +04:00
august-alt
a2d3be3f14 feat: add proxy model for administrative plugins 2022-10-28 05:28:06 +04:00
august-alt
e5628b78f2 fix: refactor preferences snap-in 2022-10-28 05:20:20 +04:00
august-alt
1d3cd8fb09 feat: add administrative templates widget 2022-10-27 16:35:04 +04:00
august-alt
d24cc19fa4 chore: update menu translation 2022-10-27 15:09:12 +04:00
august-alt
f87e3fd00d fix: remove dependency on administrative_templates snap-in 2022-10-26 09:46:15 +04:00
august-alt
41186d9445 fix: mark lambdas in administrative templates snap-in noexcept 2022-10-26 09:29:37 +04:00
august-alt
7d15033859 fix: remove gui dependency on administrative-templates plugin 2022-10-26 09:15:50 +04:00
august-alt
950abd3725 chore: update translation for tab name in preferences snap-in widgets 2022-10-26 09:02:35 +04:00
august-alt
2cbe0830c4 feat: add translation for common folder 2022-10-26 09:01:57 +04:00
august-alt
63d15eff1f fix: update cmake files for preferences snap-in 2022-10-26 09:01:14 +04:00
august-alt
8673e160d4 fix: remove debug output in translation utils 2022-10-26 09:00:16 +04:00
august-alt
78ddae3973 chore: move preferences entities to common folder 2022-10-26 08:44:12 +04:00
august-alt
e14d73416b feat: implement translation in preferences snap-in 2022-10-25 18:32:40 +04:00
august-alt
272ab6c27a chore: rename translation files 2022-10-25 18:30:03 +04:00
august-alt
6ef6ada76b fix: update model builders fix names 2022-10-25 16:21:35 +04:00
august-alt
6e53ee1172 fix: fix registry model builder 2022-10-25 12:15:12 +04:00
august-alt
a8413a9b49 fix: support boolean/integer parameters in model builders 2022-10-24 19:19:30 +04:00
august-alt
90b25415b5 fix: replace xs:bool with xs:integer in schemas 2022-10-24 19:19:01 +04:00
august-alt
c1f990bafb fix: fix user limit in networt shares 2022-10-21 17:40:26 +04:00
august-alt
11ffc8c694 fix: fix action save 2022-10-21 16:18:07 +04:00
august-alt
31cd0004f3 fix: fix files model builder, fix modelToSchema method 2022-10-19 21:41:28 +04:00
august-alt
1af67d7eb7 fix: run setupListeners on container elements to update ui 2022-10-19 20:47:27 +04:00
august-alt
506bc2ee87 fix: fix path for preferences 2022-10-19 20:46:46 +04:00
august-alt
27e6539332 fix: fix creation of model elements 2022-10-19 20:37:38 +04:00
august-alt
464daeede6 feat: add implement model writer and builder 2022-10-18 16:02:01 +04:00
august-alt
de659359b2 fix: fix registry schema 2022-10-18 16:01:08 +04:00
august-alt
130751a996 feat: add debug to modelwriter 2022-10-17 15:35:59 +04:00
august-alt
302b891b23 feat: update creation of content widget 2022-10-17 15:35:35 +04:00
august-alt
3098e19695 fix: remove writing of null pointer 2022-10-17 15:35:00 +04:00
august-alt
cfd6b6e43b feat: move PreferencesSnapInPrivate class to separate file 2022-10-17 15:24:42 +04:00
august-alt
67e8d4d0d3 fix: update preferences writes to use ostream 2022-10-17 15:23:18 +04:00
august-alt
8a60e96602 feat: add on ok press signal 2022-10-17 15:20:01 +04:00
august-alt
f54ae2fc87 feat: implement onDataSave in preferences snap-in 2022-10-14 19:06:22 +04:00
august-alt
7dc1f4c872 feat, build: update CMakeLists.txt add writer files 2022-10-14 19:05:53 +04:00
august-alt
a40715b8d6 feat: update model writer 2022-10-14 19:04:48 +04:00
august-alt
76d4015931 feat: add environment vartiables preferences writer 2022-10-14 19:04:23 +04:00
august-alt
947245e024 feat: add shortcuts preferences writer 2022-10-14 19:03:21 +04:00
august-alt
5f09243ba9 feat: add shares preferences writer 2022-10-14 19:03:06 +04:00
august-alt
8d0d1ff805 feat: add registry preferences writer 2022-10-14 19:02:54 +04:00
august-alt
7efa4b4be9 feat: add ini preferences writer 2022-10-14 19:02:42 +04:00
august-alt
057d47135d feat: add folders preferences writer 2022-10-14 19:02:32 +04:00
august-alt
270fc1b79d feat: add files preferences writer 2022-10-14 19:01:58 +04:00
august-alt
33e936b3ce feat: add preferences writer base 2022-10-14 18:59:33 +04:00
august-alt
1564eaacfe feat: add model writer 2022-10-14 16:36:29 +04:00
august-alt
4e94f490a9 fix: update widget frame 2022-10-13 14:35:50 +04:00
august-alt
c6ff20e442 fix: add content widget switch between list and data 2022-10-11 17:05:18 +04:00
august-alt
98e631523a fix: fix preferences model creation 2022-10-10 19:32:49 +04:00
august-alt
24a3e3c65b feat: add widget policy role 2022-10-10 19:32:34 +04:00
august-alt
533fdd0c42 feat: update content widget show snap-in widget 2022-10-10 19:32:07 +04:00
august-alt
ba9f41bb83 fix: update reades 2022-10-10 19:30:58 +04:00
august-alt
c556d9aea8 chore: refactor content widget, remove direct dependency on administrative template snap-in 2022-10-06 17:47:53 +04:00
august-alt
33ffa4e0ea chore: update comments in administrative templates snap-in 2022-10-05 18:36:01 +04:00
august-alt
81732d1cdd wip: update save function in administrative templates snap-in 2022-10-05 18:19:13 +04:00
august-alt
e045273b6c wip: update administrative templates snap-in 2022-10-05 17:18:20 +04:00
august-alt
7eb094ba89 feat: add method onRetranslateUI to ISnapIn 2022-10-04 17:09:23 +04:00
august-alt
8c668fb4f6 feat: update preferences tree model 2022-10-04 15:53:56 +04:00
august-alt
b81ba916b1 wip: load data from snap-ins 2022-10-03 14:17:23 +04:00
august-alt
726d11955e chore: add onDataLoad and onDataSave to snap-in 2022-10-03 14:16:48 +04:00
august-alt
5ca4d29597 fix: fix model creator add check for nullptr 2022-10-03 14:14:27 +04:00
august-alt
71bf40dead feat, build: update spec file, increase version 2022-09-29 17:13:36 +04:00
august-alt
21a2b51cfa Merge branch 'master' of github.com:august-alt/gpui 2022-09-29 17:02:16 +04:00
august-alt
a10a5459bf fix: remove vertical margins in name label 2022-09-29 16:54:47 +04:00
august-alt
0dc478e81a
Merge pull request #8 from Samael340/master
contentwidget.cpp has been changed
2022-09-29 16:48:19 +04:00
august-alt
0d40dee78e
Merge pull request #9 from AlexSP0/fix_enum_element_types
fix: enum element types
2022-09-29 14:22:41 +04:00
bc88165145 changed variable name from primordialState to initialState 2022-09-28 18:26:00 +04:00
august-alt
a6a1e4fd42 fix: add ld library path 2022-09-28 18:21:32 +04:00
august-alt
bc33886a13 feat: add loading of default snap-ins 2022-09-28 16:19:33 +04:00
august-alt
9963b86388 gix: update spec file add preferences snap-in 2022-09-28 16:02:59 +04:00
august-alt
d18694c0f6 feat: add preferences snap-in library 2022-09-28 15:56:27 +04:00
Alexey Saprunov
5c58b2ff1d fix: enum element types 2022-09-28 14:59:12 +04:00
august-alt
f759948957 fix: update spec file set relaxed dependencies search for verify-elf 2022-09-28 13:42:36 +04:00
august-alt
7dbafde441 fix: remove extra exported symbols from administrative templates plugin 2022-09-28 12:23:20 +04:00
august-alt
581fb6713a fix: remove filedialogutils.h from moc files 2022-09-28 12:01:43 +04:00
august-alt
4b42c16a92 chore: update .gitignore exclude generated schemas 2022-09-28 12:01:11 +04:00
august-alt
593408e962 fix: remove generated schemas 2022-09-28 11:56:51 +04:00
august-alt
061ef86676 feat: add administrative templates plugin 2022-09-27 17:59:50 +04:00
august-alt
39df2e6710 build, fix: remove dependencies on core library 2022-09-27 17:57:55 +04:00
august-alt
b79935c5a0 build: remove model library 2022-09-27 17:57:10 +04:00
august-alt
a0c0a16d82 build: update spec file 2022-09-27 14:19:41 +04:00
august-alt
61677e3ea8 feat: add core library 2022-09-27 14:17:19 +04:00
august-alt
70676bcb06 feat: update spec file remove deleted library entries 2022-09-26 18:45:36 +04:00
august-alt
52f0484922 feat, build: update spec file add libqtmvvm, update github workflow 2022-09-26 18:27:58 +04:00
august-alt
448f281eb3 feat: add empty core library 2022-09-26 18:22:31 +04:00
august-alt
6aa2f4b904 feat: add preferences static library 2022-09-26 17:54:35 +04:00
august-alt
4ed90b4455 feat: add file dialog utils 2022-09-26 17:40:12 +04:00
august-alt
f725f6831e feat: remove preferences folder 2022-09-26 13:32:57 +04:00
Samael340
65f9a4f3ab
Add files via upload 2022-09-20 17:25:46 +04:00
august-alt
bd7355854b 0.2.15-alt1
- Fixes:
  + #81760 Fix disabled and enabled list in policies.
2022-08-04 17:52:15 +04:00
august-alt
09d9cc75fc fix: fix issue #81760 2022-08-04 16:24:26 +04:00
august-alt
461ea1e1ff fix: fix issue #76818, clear search line edit on language change 2022-06-07 15:54:03 +04:00
august-alt
fa0130d852 0.2.14-alt1
- Fixes:
  + Vesioning improved.
  + Fixed build on e2k platform.
2022-04-18 15:33:08 +04:00
august-alt
9b896d3d6a fix: fix build on e2k 2022-04-12 05:08:15 +04:00
august-alt
dca9586351 fix: fix issue with item selection after displaying of messagebox, fix: #74198 2022-04-08 15:46:02 +04:00
august-alt
46699ad39d fix: fix data type for decimal fields 2022-04-07 15:50:03 +04:00
august-alt
26d3316bae fix: fix location of application settings 2022-04-07 14:59:44 +04:00
august-alt
710f36215e fix: only set policy name if it is not provided 2022-04-05 09:56:17 +04:00
august-alt
c9eca449f0 fix: prevent double message box 2022-04-04 17:55:09 +04:00
august-alt
f953ae5986 0.2.0-alt13
- Fixes:
  + #75065 Add workaround for bug #75065.
2022-04-04 15:19:55 +04:00
august-alt
cc23c3767e fix: remove message box on read of a file, #75065 2022-04-04 15:09:23 +04:00
august-alt
02c10cd8f7 wip, chore: update tests 2022-04-01 22:45:08 +04:00
august-alt
18a5d6f837 0.2.0-alt12
- Fixes:
  + Fix -n command line option.
2022-03-31 16:35:27 +04:00
august-alt
590098fdc6 fix: add name option to command line parser 2022-03-31 12:01:07 +04:00
august-alt
a5b86cb1c8 0.2.0-alt11
- Fixes:
  + #74198 Improve ability to detect policy changes and notify user about them.
  + #74149 Fix install/removal of packages through list element.
  + #74217 Add switch between elements through keyboard.
  + #75076 Fix -b option.
  + #75070 Add decimal text box minimum and maximum.
  + #75065 Add message boxes for access errors.
  + Fix several build issues on e2k platform.
2022-03-30 12:45:38 +04:00
august-alt
5bdfc9eaea feat: add option to provide window title through admc 2022-03-30 12:30:59 +04:00
august-alt
2f116aaf2e fix: add support of lcc 2022-03-30 11:55:41 +04:00
august-alt
479f912682 fix: rename context in smbclient 2022-03-30 08:39:46 +04:00
august-alt
14e177cd56 feat: add new behaviour for lists 2022-03-30 08:35:34 +04:00
august-alt
9bb3459cdf fix: rename variables in storage plugin 2022-03-30 08:13:06 +04:00
august-alt
f99a9abf0b fix: set parent index on policy item select 2022-03-30 07:25:11 +04:00
august-alt
53a7a19e6b feat: add translations to message box 2022-03-30 07:19:37 +04:00
august-alt
0753181b63 feat: add selection of new item on arrow movement 2022-03-30 07:14:59 +04:00
august-alt
6eb0cb8389 feat, build: add inifile plugin's path to gpui.spec 2022-03-30 06:28:54 +04:00
august-alt
a286653c74 feat, build: add boost-devel-headers to gpui.spec 2022-03-30 06:27:58 +04:00
august-alt
1fb53f2fda feat: read policy display name from gpt.ini 2022-03-30 06:14:32 +04:00
august-alt
4bb29edc83 feat: add ini plugin 2022-03-30 06:14:03 +04:00
august-alt
e040572c6f fix: fix message in message box 2022-03-29 17:22:15 +04:00
august-alt
615fb033f4 fix: add message box on read error 2022-03-29 16:39:09 +04:00
august-alt
de6ba68029 fix: add minimum and maximum values to decimal text box 2022-03-29 16:05:09 +04:00
august-alt
2a22435fc0 chore: add close operation to ok button in listbox 2022-03-29 15:32:30 +04:00
august-alt
91360de39e fix: add new plugins spec file 2022-03-29 15:28:21 +04:00
august-alt
befaab9f6f fix: clear registry on adding new values to list 2022-03-29 15:17:35 +04:00
august-alt
3e5a41bd9d chore: add empty plugins for cmtx/cmtl 2022-03-28 19:19:34 +04:00
august-alt
2cfe8c1f8c fix: set correct model to content widget 2022-03-28 18:37:55 +04:00
august-alt
9a7c72d1a2 wip: add support for list element in admx 2022-03-28 18:34:07 +04:00
august-alt
968cd07b91 fix: only set admx path if it is empty, fix: #75076 2022-03-27 19:09:47 +04:00
august-alt
923e86f721 0.2.0-alt10
- Fixes:
  + #74754 Fix ability to generate pol setting for "both" policy type.
  + #74151 Fix generate Chromium/Firefox start page in pol file.
  + #75062 Prevent doubling of items in drop list.
  + #75058 Fix command name in manual.
  + #75062 Remove icons from OK/Cancel buttons.
  + #75035 Set fixed container height for label.
2022-03-25 19:32:16 +04:00
august-alt
371dcecf75 fix: remove all icons from buttons, fix: #75058 2022-03-25 19:11:40 +04:00
august-alt
ae9c27510e fix: fix issue with doubling items in drop down lists, fix: #75062 2022-03-25 15:02:34 +04:00
august-alt
93d1a923c9 fix: set fixed height of label container in content widget 2022-03-24 12:36:37 +04:00
august-alt
f231d723f9 fix: add translation to search bar 2022-03-22 17:30:57 +04:00
august-alt
af95c5600f fix: resolve issue with command name in manual 2022-03-22 13:07:57 +04:00
august-alt
37d988b510 feat: add search bar 2022-03-21 17:44:43 +04:00
august-alt
d43838cf87 fix: fix issue with group policy type both, fix: #74754, #74151 2022-03-21 16:10:53 +04:00
august-alt
2d17b52bd2 feat: add policy description to top tree view item 2022-03-21 14:55:00 +04:00
august-alt
f194f02b1a 0.2.0-alt9
- Fixes:
  + Fix segmentation fault on selecting new policy item.
  + Fix translation of message box window.
2022-03-18 15:03:09 +04:00
august-alt
d5f1d19c65 fix: fix segmentation fault on old signals been executed 2022-03-18 14:45:37 +04:00
august-alt
416248c732 fix: translate message box 2022-03-17 16:46:11 +04:00
august-alt
f0958d562d fix: fix -Wsign-cast error 2022-03-16 17:27:43 +04:00
august-alt
fedb753e0a chore: remove -Wsign-promo due to gcc7 behaviour 2022-03-16 16:08:40 +04:00
august-alt
f5ae4bdde2 0.2.0-alt8
- Fixes:
  + #74163 Fix segmentation fault on selecting item in "security category".
  + #74704 Fix window resize on label resize.
  + #74050 Fix cancel buttons translation.
  + #74050 Man was added.
2022-03-16 15:57:10 +04:00
august-alt
e2b79d075d fix: fix window resize on large labels, fix: #74704 2022-03-16 15:07:15 +04:00
august-alt
5e37207956 fix: fix translations of default dialog buttons, fix: #74050 2022-03-16 14:00:08 +04:00
august-alt
33843ddfc2 chore, fix: correct file extention of man pages 2022-03-16 13:23:25 +04:00
august-alt
692bc9ad73 chore: add verbose flag to install script 2022-03-16 13:10:40 +04:00
august-alt
74b745544c feat: add man pages, fix: #73749 2022-03-16 12:46:37 +04:00
august-alt
0d50def373 fix: add translation to file type in open dialog 2022-03-16 11:55:19 +04:00
august-alt
98028a1deb fix: fix repocop warning adding aditional desktop category 2022-03-15 19:18:49 +04:00
august-alt
9844858b02 fix: initialize smb file permissions with a constructor 2022-03-15 19:07:36 +04:00
august-alt
84e239cfe8 chore: enable more gcc warnings and fix them 2022-03-15 18:56:02 +04:00
august-alt
5cff440559 chore: warnings associated with -Weffc++ flag were corrected 2022-03-15 16:09:06 +04:00
august-alt
c8fc6f0b4b 0.2.0-alt7
- Fixes:
  + #74215 Add message for the change of policy's state.
  + #74217 Add ability to select policies with keyboard.
  + #74208 Add policy name label.
  + #74172 Make list dialog modal.
  + #74005 Remove empty folders from tree view.
  + #74015 Add ability to resize right frame.
  + #74028 Remove --help-all command argument.
  + #74046 Improve sort order of tree view.
  + #74054 Fix ability to save integer values.
2022-03-14 17:57:51 +04:00
august-alt
ab42a8dd6d fix: second attempt on fixing integer saving, fix: #74054 2022-03-14 17:33:36 +04:00
august-alt
a506a6e5b0 fix: prevent multiple dialogs from opening, fix: #74172 2022-03-14 15:42:01 +04:00
august-alt
2f07f18282 fix: add policy name to content widget, fix: #74208 2022-03-14 15:13:57 +04:00
august-alt
a50b606f2a chore: update splitters in content widget 2022-03-14 14:53:06 +04:00
august-alt
7d9e30a65d chore: update splitter in main window 2022-03-14 14:28:06 +04:00
august-alt
faa58f4d3f chore: change content widget size policy 2022-03-14 11:22:39 +04:00
august-alt
8f6bd33a97 chore: add strech to splitter in content widget 2022-03-13 18:44:37 +04:00
august-alt
91e7eda788 chore: update tab ordering 2022-03-13 18:12:23 +04:00
august-alt
18770edd4b feat, fix: add ability to select items with keyboard, fix #74217 2022-03-13 18:07:40 +04:00
august-alt
2f8b6d5296 feat: add horizontal splitter 2022-03-13 15:42:50 +04:00
august-alt
4e56ab11f2 fix: remove help-all option, fix #74028 2022-03-13 14:45:00 +04:00
august-alt
006469792c fix: add folders first order of items, fix: #74046 2022-03-04 17:28:52 +04:00
august-alt
dfd62c0822 feat: add statusbar text, fix: #74215 2022-03-04 16:52:03 +04:00
august-alt
591ea078c8 fix: fix issue with showing empty items, fix: #74005 2022-03-02 18:18:51 +04:00
august-alt
d8e572185f 0.2.0-alt6
- Fixes:
  + #74114 Fix ability to load ADMX bundle.
2022-03-01 16:31:53 +04:00
august-alt
b39e1a25d3 fix: fix issue with loading of admx bundle, fix #74114 2022-03-01 16:29:23 +04:00
903 changed files with 95120 additions and 39218 deletions

114
.clang-format Normal file
View File

@ -0,0 +1,114 @@
# Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com>
#
# You may use this file under the terms of the 3-clause BSD license.
# See the file LICENSE from this package for details.
# This is the clang-format configuration style to be used by Qt,
# based on the rules from https://wiki.qt.io/Qt_Coding_Style and
# https://wiki.qt.io/Coding_Conventions
---
# Webkit style was loosely based on the Qt style
BasedOnStyle: WebKit
Standard: c++17
# Column width is limited to 100 in accordance with Qt Coding Style.
# https://wiki.qt.io/Qt_Coding_Style
# Note that this may be changed at some point in the future.
ColumnLimit: 100
# How much weight do extra characters after the line length limit have.
# PenaltyExcessCharacter: 4
# Disable reflow of some specific comments
# qdoc comments: indentation rules are different.
# Translation comments and SPDX license identifiers are also excluded.
CommentPragmas: "^!|^:|^ SPDX-License-Identifier:"
# We want a space between the type and the star for pointer types.
PointerBindsToType: false
# We generally use "template <" with space.
SpaceAfterTemplateKeyword: true
# We want to break before the operators, but not before a '='.
BreakBeforeBinaryOperators: NonAssignment
# Braces are usually attached, but not after functions or class declarations.
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
# When constructor initializers do not fit on one line, put them each on a new line.
ConstructorInitializerAllOnOneLineOrOnePerLine: true
# Indent initializers by 4 spaces
ConstructorInitializerIndentWidth: 4
# Indent width for line continuations.
ContinuationIndentWidth: 8
# No indentation for namespaces.
NamespaceIndentation: None
# Allow indentation for preprocessing directives (if/ifdef/endif). https://reviews.llvm.org/rL312125
IndentPPDirectives: AfterHash
# We only indent with 2 spaces for preprocessor directives
PPIndentWidth: 2
# Horizontally align arguments after an open bracket.
# The coding style does not specify the following, but this is what gives
# results closest to the existing code.
AlignAfterOpenBracket: true
AlwaysBreakTemplateDeclarations: true
# Ideally we should also allow less short function in a single line, but
# clang-format does not handle that.
AllowShortFunctionsOnASingleLine: Inline
# The coding style specifies some include order categories, but also tells to
# separate categories with an empty line. It does not specify the order within
# the categories. Since the SortInclude feature of clang-format does not
# re-order includes separated by empty lines, the feature is not used.
SortIncludes: false
# macros for which the opening brace stays attached.
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ]
# Break constructor initializers before the colon and after the commas.
BreakConstructorInitializers: BeforeColon
# Add "// namespace <namespace>" comments on closing brace for a namespace
# Ignored for namespaces that qualify as a short namespace,
# see 'ShortNamespaceLines'
FixNamespaceComments: true
# Definition of how short a short namespace is, default 1
ShortNamespaceLines: 1
# When escaping newlines in a macro attach the '\' as far left as possible, e.g.
##define a \
# something; \
# other; \
# thelastlineislong;
AlignEscapedNewlines: Left
# Avoids the addition of a space between an identifier and the
# initializer list in list-initialization.
SpaceBeforeCpp11BracedList: false
---
# Use the Google-based style for .proto files.
Language: Proto
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 100

View File

@ -1,8 +1,8 @@
%define _unpackaged_files_terminate_build 1
Name: gpui
Version: 0.2.0
Release: alt5
Version: 0.2.55
Release: alt1
Summary: Group policy editor
License: GPLv2+
@ -18,13 +18,28 @@ BuildRequires: qt5-declarative-devel
BuildRequires: qt5-tools-devel
BuildRequires: libsmbclient-devel libsmbclient
BuildRequires: samba-devel
BuildRequires: libldap-devel
BuildRequires: libsasl2-devel
BuildRequires: libsmbclient-devel
BuildRequires: libuuid-devel
BuildRequires: glib2-devel
BuildRequires: libpcre-devel
BuildRequires: libkrb5-devel
BuildRequires: libgtest-devel
BuildRequires: qt5-base-common
BuildRequires: doxygen
BuildRequires: libxerces-c-devel
BuildRequires: xsd
BuildRequires: boost-devel-headers
BuildRequires: desktop-file-utils ImageMagick-tools
BuildRequires: libqt-mvvm-devel
BuildRequires: xorg-xvfb xvfb-run
Requires: admx-basealt
Source0: %name-%version.tar
@ -53,28 +68,36 @@ for size in 48 64 128 256 512; do
%buildroot%_datadir/icons/hicolor/''${size}x''${size}/apps/gpui.png
done
install -v -p -m 644 -D ../setup/man/en/gpui.1 %buildroot%_man1dir/gpui.1
install -v -p -m 644 -D ../setup/man/ru/gpui.1 %buildroot%_mandir/ru/man1/gpui.1
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:%_libdir/gpui/plugins/
LD_PRELOAD=%buildroot%_libdir/gpui/plugins/libadministrative-templates-plugin.so
%files
%doc README.md
%doc INSTALL.md
%_bindir/gpui-main
%_libdir/libgpui-core.so
%_libdir/libgpui-gui.so
%_libdir/libgpui-io.so
%_libdir/libgpui-model.so
%_libdir/libgpui-ldap.so
%_libdir/gpui/plugins/libadministrative-templates-plugin.so
%_libdir/gpui/plugins/libpreferences-plugin.so
%_libdir/gpui/plugins/libadml-plugin.so
%_libdir/gpui/plugins/libadmx-plugin.so
%_libdir/gpui/plugins/libcmtl-plugin.so
%_libdir/gpui/plugins/libcmtx-plugin.so
%_libdir/gpui/plugins/libinifile-plugin.so
%_libdir/gpui/plugins/libinifile-ascii-plugin.so
%_libdir/gpui/plugins/libreg-plugin.so
%_libdir/gpui/plugins/libspol-plugin.so
%_libdir/gpui/plugins/libpol-plugin.so
%_libdir/gpui/plugins/libdrives-plugin.so
%_libdir/gpui/plugins/libfiles-plugin.so
%_libdir/gpui/plugins/libfolders-plugin.so
%_libdir/gpui/plugins/libini-plugin.so
%_libdir/gpui/plugins/libshares-plugin.so
%_libdir/gpui/plugins/libshortcuts-plugin.so
%_libdir/gpui/plugins/libvariables-plugin.so
%_libdir/gpui/plugins/libscripts-plugin.so
%_libdir/gpui/plugins/libsmb-storage-plugin.so
@ -86,7 +109,415 @@ done
%_desktopdir/gpui.desktop
%_man1dir/gpui.*
%_mandir/ru/man1/gpui.*
%changelog
* Fri Oct 11 2024 Vladimir Rubanov <august@altlinux.org> 0.2.55-alt1
- 0.2.54-alt1
- Fixes:
+ Fix list values dialog (Closes: 51681).
* Mon Oct 4 2024 Vladimir Rubanov <august@altlinux.org> 0.2.54-alt1
- 0.2.54-alt1
- Fixes:
+ Fix list values saving in administrative templates (Closes: 51587).
* Mon Sep 16 2024 Vladimir Rubanov <august@altlinux.org> 0.2.53-alt1
- 0.2.53-alt1
- Fixes:
+ Fix add ascii ini file plugin (Closes: 51451, 51466, 47576).
* Fri Sep 13 2024 Vladimir Rubanov <august@altlinux.org> 0.2.52-alt1
- 0.2.52-alt1
- Fixes:
+ Fix comment path on smb share.
+ Fix group policy template name.
* Fri Sep 13 2024 Vladimir Rubanov <august@altlinux.org> 0.2.51-alt1
- 0.2.51-alt1
- Fixes:
+ Fix group policy template name in scripts dialog.
* Mon Sep 2 2024 Vladimir Rubanov <august@altlinux.org> 0.2.50-alt1
- 0.2.50-alt1
- Fixes:
+ Fix group policy template version update.
* Wed Aug 28 2024 Vladimir Rubanov <august@altlinux.org> 0.2.49-alt1
- 0.2.49-alt1
- Fixes:
+ Add support for smb located comments.
* Tue Aug 20 2024 Vladimir Rubanov <august@altlinux.org> 0.2.48-alt1
- 0.2.48-alt1
- Fixes:
+ Fix order of pol instructions in internal storage.
+ Fix list based policies (Closes: 50123).
+ Fix comment values (Closes: 47576).
+ Fix script settings description (Closes: 49099).
* Tue Aug 6 2024 Vladimir Rubanov <august@altlinux.org> 0.2.47-alt1
- 0.2.47-alt1
- Fixes:
+ Fix pol parser validation.
* Tue Aug 6 2024 Vladimir Rubanov <august@altlinux.org> 0.2.46-alt1
- 0.2.46-alt1
- Fixes:
+ Fix saving of square brakets in pol file (Closes: 50706).
+ Fix checkbox based policies (Closes: 48970, 47742).
* Fri Jun 6 2024 Vladimir Rubanov <august@altlinux.org> 0.2.45-alt1
- 0.2.45-alt1
- Fixes:
+ Fix creation of gpt.ini while saving.
* Fri Apr 1 2024 Vladimir Rubanov <august@altlinux.org> 0.2.44-alt1
- 0.2.44-alt1
- Fixes:
+ Fix admx-firefox elements order (Closes: 47727).
+ Fix memory leak in ini plugin.
+ Fix file widget in preferences plugin.
* Fri Mar 15 2024 Vladimir Rubanov <august@altlinux.org> 0.2.43-alt1
- 0.2.43-alt1
- Fixes:
+ Fix build with samba 4.20.rc4.
* Wed Mar 6 2024 Vladimir Rubanov <august@altlinux.org> 0.2.42-alt1
- 0.2.42-alt1
- Features:
+ Add environment variables dialog to preferences.
* Tue Feb 29 2024 Vladimir Rubanov <august@altlinux.org> 0.2.41-alt1
- 0.2.41-alt1
- Features:
+ Add edit entry to preferences context menu (Closes: 49098).
- Fixes:
+ Fix admx-firefox elements order (Closes: 44507).
+ Fix text elements order (Closes: 49053).
* Tue Dec 26 2023 Vladimir Rubanov <august@altlinux.org> 0.2.40-alt1
- 0.2.40-alt1
- Fixes:
+ Fix replace path with name in script dialog.
* Mon Dec 25 2023 Vladimir Rubanov <august@altlinux.org> 0.2.39-alt1
- 0.2.39-alt1
- Fixes:
+ Fix add script dialog.
+ Fix script's folder creation.
* Fri Oct 13 2023 Vladimir Rubanov <august@altlinux.org> 0.2.38-alt1
- 0.2.38-alt1
- Fixes:
+ Fix ldap guid path.
* Fri Oct 13 2023 Vladimir Rubanov <august@altlinux.org> 0.2.37-alt1
- 0.2.37-alt1
- Fixes:
+ Fix "both" policy type.
+ Fix extensions guid in gpc.
* Mon Oct 09 2023 Vladimir Rubanov <august@altlinux.org> 0.2.36-alt1
- 0.2.36-alt1
- Fixes:
+ Emergency fix for invalid pol files.
* Thu Oct 05 2023 Vladimir Rubanov <august@altlinux.org> 0.2.35-alt1
- 0.2.35-alt1
- Fixes:
+ Fix subsequent deletion of multiple elements in scripts dialog (Closes: 47553).
+ Fix desktop file entry.
+ Fix add folder name to script path.
* Mon Sep 04 2023 Vladimir Rubanov <august@altlinux.org> 0.2.34-alt1
- 0.2.34-alt1
- Fixes:
+ Fix translations language list (Closes: 47437).
+ Fix translations for comment in administrative templates plugin (Fixes: 109650).
+ Fix scripts encoding to UTF-16LE.
+ Remove browse button from add script widget.
* Fri Sep 01 2023 Vladimir Rubanov <august@altlinux.org> 0.2.33-alt1
- 0.2.33-alt1
- Fixes:
+ Fix translations for path and parameters in scripts plugin (Closes: 47133).
+ Fix show files button in scripts plugin (Closes: 47136).
+ Fix list parameters in administrative templates plugin (Closes: 47137).
- Features:
+ New logging system.
* Fri Jul 21 2023 Vladimir Rubanov <august@altlinux.org> 0.2.32-alt1
- 0.2.32-alt1
- Features:
+ Implement support of platforms in filter dialog.
* Wed Jul 19 2023 Vladimir Rubanov <august@altlinux.org> 0.2.31-alt1
- 0.2.31-alt1
- Fixes:
+ Fix scripts plugin.
* Fri Jul 14 2023 Vladimir Rubanov <august@altlinux.org> 0.2.30-alt1
- 0.2.30-alt1
- Fixes:
+ Fix comments plugin.
* Thu Jul 13 2023 Vladimir Rubanov <august@altlinux.org> 0.2.29-alt1
- 0.2.29-alt1
- Fixes:
+ Add comments support.
* Wed Jun 21 2023 Vladimir Rubanov <august@altlinux.org> 0.2.28-alt1
- 0.2.28-alt1
- Fixes:
+ Fix update of administrative templates filter dialog.
* Tue Jun 20 2023 Vladimir Rubanov <august@altlinux.org> 0.2.27-alt1
- 0.2.27-alt1
- Features:
+ Implement administrative templates filter dialog.
* Wed Jun 07 2023 Vladimir Rubanov <august@altlinux.org> 0.2.26-alt1
- 0.2.26-alt1
- Fixes:
+ Fix policies with value name only. (Closes: 46082).
+ Fix namespaces. (Closes: 46282).
* Fri May 19 2023 Vladimir Rubanov <august@altlinux.org> 0.2.25-alt1
- 0.2.25-alt1
- Fixes:
+ Fix application launch without arguments (Closes: 46189).
* Tue Apr 11 2023 Vladimir Rubanov <august@altlinux.org> 0.2.24-alt1
- 0.2.24-alt1
- Fixes:
+ Fix laguage loading in plugins.
+ Fix tests.
* Wed Apr 05 2023 Vladimir Rubanov <august@altlinux.org> 0.2.23-alt1
- 0.2.23-alt1
- Fixes:
+ Fix support for files without extensions in files preference.
* Wed Mar 29 2023 Vladimir Rubanov <august@altlinux.org> 0.2.22-alt1
- 0.2.22-alt1
- Fixes:
+ Fix policy path in scripts plugin.
* Mon Mar 27 2023 Vladimir Rubanov <august@altlinux.org> 0.2.21-alt1
- 0.2.21-alt1
- Fixes:
+ Add button to clear key sequence in shortcuts widget.
+ Fix typos in folder preferences.
+ Fix writing script to smb shares.
* Sun Mar 05 2023 Vladimir Rubanov <august@altlinux.org> 0.2.20-alt1
- 0.2.20-alt1
- Fixes:
+ Fix policy's key search for lists in administrative templates.
* Sun Mar 05 2023 Vladimir Rubanov <august@altlinux.org> 0.2.19-alt1
- 0.2.19-alt1
- Fixes:
+ Replace std::regex with QRegularExpression in scripts module.
* Thu Jan 19 2023 Vladimir Rubanov <august@altlinux.org> 0.2.18-alt1
- 0.2.18-alt1
- Features:
+ Implement scripts module.
* Thu Jan 19 2023 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt18
- 0.2.17-alt18
- Fixes:
+ Fix input in section field in ini widget on delete action.
+ Fix set default setting to true for user context in user policies.
* Thu Jan 12 2023 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt17
- 0.2.17-alt17
- Fixes:
+ #91098 Fix translations for shortcuts widget on KDE systems.
* Tue Jan 10 2023 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt16
- 0.2.17-alt16
- Fixes:
+ #91098 Fix translations for shortcuts widget.
+ #88126 Implement shortcuts key sequence encoding.
* Wed Dec 28 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt15
- 0.2.17-alt15
- Fixes:
+ #91635 Fix e2k preferences build.
+ #91629 Fix translations on e2kv4.
+ #75874 Change spinbox behaviour to mimic windows behaviour.
+ #89621 Fix typo in ini widget.
+ #91060 Fix OK and Cancel buttons to work in a message box.
* Mon Dec 26 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt14
- 0.2.17-alt14
- Fixes:
+ #91097 Fix names of hidden and archive fields in folder widget.
+ #91237 Remove sorting in table header.
+ #90987 Fix status bar message.
+ #91312 Add translation to '-n' command line option.
+ #91047 Fix segmentation fault in the absence of kerberos tickets.
* Thu Dec 15 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt13
- 0.2.17-alt13
- Fixes:
+ Fix presentation builder to allow build on e2k.
* Thu Dec 15 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt12
- 0.2.17-alt12
- Fixes:
+ Fix e2k build.
* Fri Dec 09 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt11
- 0.2.17-alt11
- Fixes:
+ #89597 Fix message box.
+ #88897 Ask to save changes.
+ #75885 Add sort to drop down list elements.
+ Fix set correct resource for non existent registry.pol files.
+ Fix copy policy to copied item.
+ #76835 Fix policy names.
+ #88907 Fix google chrome policies handling.
* Tue Dec 06 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt10
- 0.2.17-alt10
- Fixes:
+ #89553 Switch search to be case insensitive.
+ #89558 Fix translations of shortcuts widget.
+ #89561 Fix russian translations in properties widget.
+ #89621 Fix ini file's widget translations.
+ #89692 Fix translation of shortcuts widget.
+ #89648 Fix russian translation of shares widget.
+ #89648 Fix russian translation of common widget.
* Wed Nov 30 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt9
- 0.2.17-alt9
- Fixes:
+ Fix null pointer in ldap library.
+ Fix invalid drive name.
* Tue Nov 29 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt8
- 0.2.17-alt8
- Fixes:
+ #88602 Fix creation of network share's attributes.
+ #88794 Fix drive map's xml structure.
+ #44378 Allow empty section name in ini widget.
+ #74009 Remove labels in empty widget.
+ #88711 Modify model builder of network shares to write only required fields.
+ #88844 Fix save of admx path setting.
* Wed Nov 16 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt7
- 0.2.17-alt7
- Fixes:
+ #88813 Fix restore dependency on admx-basealt.
+ #88495 Fix translations in environment variable widget.
+ #88226 Fix folder creation.
+ #88143 Fix folder attributes during deletion of folders.
+ #88586 Fix russian translation of mapped drive context menu.
* Wed Nov 16 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt6
- 0.2.17-alt6
Features:
+ Add mapped drives for computers and network shares for user.
* Wed Nov 16 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt5
- 0.2.17-alt5
- Fixes:
+ #88226 Fix inability to create folders.
+ #88226 Fix inability to create files.
+ Restore n option.
* Fri Nov 11 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt4
- 0.2.17-alt4
- Features:
+ Add custom tree view for preferences.
* Fri Nov 11 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt3
- 0.2.17-alt3
- Fixes:
+ #74208 Fix group policy name.
+ Fix translations in administrative templates plugin.
* Thu Nov 10 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt2
- 0.2.17-alt2
* Thu Nov 03 2022 Vladimir Rubanov <august@altlinux.org> 0.2.17-alt1
- 0.2.17
* Thu Sep 29 2022 Vladimir Rubanov <august@altlinux.org> 0.2.16-alt1
- Fixes:
+ #84127 Fix invalid types for list enums.
+ #76835 Fix message on policy state change.
* Thu Aug 04 2022 Vladimir Rubanov <august@altlinux.org> 0.2.15-alt1
- Fixes:
+ #81760 Fix disabled and enabled list in policies.
* Mon Apr 18 2022 Vladimir Rubanov <august@altlinux.org> 0.2.14-alt1
- Fixes:
+ Vesioning improved.
+ Fixed build on e2k platform.
* Fri Apr 04 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt13
- Fixes:
+ #75065 Add workaround for bug #75065.
* Fri Mar 31 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt12
- Fixes:
+ Fix -n command line option.
* Fri Mar 30 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt11
- Fixes:
+ #74198 Improve ability to detect policy changes and notify user about them.
+ #74149 Fix install/removal of packages through list element.
+ #74217 Add switch between elements through keyboard.
+ #75076 Fix -b option.
+ #75070 Add decimal text box minimum and maximum.
+ #75065 Add message boxes for access errors.
+ Fix several build issues on e2k platform.
* Fri Mar 25 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt10
- Fixes:
+ #74754 Fix ability to generate pol setting for "both" policy type.
+ #74151 Fix generate Chromium/Firefox start page in pol file.
+ #75062 Prevent doubling of items in drop list.
+ #75058 Fix command name in manual.
+ #75062 Remove icons from OK/Cancel buttons.
+ #75035 Set fixed container height for label.
* Fri Mar 18 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt9
- Fixes:
+ Fix segmentation fault on selecting new policy item.
+ Fix translation of message box window.
* Wed Mar 16 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt8
- Fixes:
+ #74163 Fix segmentation fault on selecting item in "security category".
+ #74704 Fix window resize on label resize.
+ #74050 Fix cancel buttons translation.
+ #74050 Man was added.
* Mon Mar 14 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt7
- Fixes:
+ #74215 Add message for the change of policy's state.
+ #74217 Add ability to select policies with keyboard.
+ #74208 Add policy name label.
+ #74172 Make list dialog modal.
+ #74005 Remove empty folders from tree view.
+ #74015 Add ability to resize right frame.
+ #74028 Remove --help-all command argument.
+ #74046 Improve sort order of tree view.
+ #74054 Fix ability to save integer values.
* Tue Mar 01 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt6
- Fixes:
+ #74114 Fix ability to load ADMX bundle.
* Mon Feb 28 2022 Vladimir Rubanov <august@altlinux.org> 0.2.0-alt5
- Fixes:
+ #73976 Correct dialog flags to provide ability to select folders.

42
.github/workflows/build-container.yml vendored Normal file
View File

@ -0,0 +1,42 @@
name: gpui-build-container
on:
workflow_call:
inputs:
distr:
description: "Linux distribution"
type: string
required: true
architecture:
description: "Architecture"
type: string
required: true
jobs:
gpui-build-container:
runs-on: ubuntu-latest
steps:
- name: Checkout
if: github.ref == 'refs/heads/master'
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
if: github.ref == 'refs/heads/master'
run: |
docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.github_token }}
- name: Build container
if: github.ref == 'refs/heads/master'
run: |
docker buildx build -t ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:${{ github.run_number }} \
-t ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:latest \
--cache-from type=gha,scope=$GITHUB_REF_NAME-${{ inputs.architecture }}-image \
--cache-to type=gha,mode=max,scope=$GITHUB_REF_NAME-${{ inputs.architecture }}-image \
--build-arg DISTR=${{ inputs.distr }} --build-arg ARCH=${{ inputs.architecture }} \
--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) --platform ${{ inputs.architecture }} .
- name: Push container
if: github.ref == 'refs/heads/master'
run: |
docker push -a ghcr.io/${{ github.repository }}-${{ inputs.architecture }}

41
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,41 @@
name: gpui-build
on:
workflow_call:
inputs:
artifact:
description: "Artifact"
type: string
required: true
architecture:
description: "Architecture"
type: string
required: true
jobs:
gpui-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build GPUI packages
run: |
docker pull --platform linux/${{ inputs.architecture }} \
ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:latest
docker run --privileged=true --name gpui-build-${{ inputs.architecture }} -i --log-driver=none \
-a stdin -a stdout -a stderr -v "$(pwd)":/app --platform linux/${{ inputs.architecture }} \
ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:latest
- name: Extract fresh packages
if: github.ref == 'refs/heads/master'
run: |
docker cp gpui-build-${{ inputs.architecture }}:/home/builder2/RPM/RPMS/ "$(pwd)/packages"
- name: Upload fresh RPM packages
if: github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v3
with:
name: gpui-${{ inputs.artifact }}-${{ inputs.architecture }}
path: ${{ github.workspace }}/packages

View File

@ -1,43 +1,40 @@
name: "CodeQL"
name: gpui-codeql-analysis
on: [ push, pull_request ]
on:
workflow_call:
inputs:
architecture:
description: "Architecture"
type: string
required: true
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
container: alt:p9
gpui-codeql-analysis:
runs-on: ubuntu-20.04
container: ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: cpp
- name: Update software
run: apt-get update
- name: Configure cmake
run: cmake -B build .
- name: Install software
run: apt-get install -y git cmake rpm-macros-cmake cmake-modules gcc-c++ qt5-base-devel qt5-tools-devel qt5-base-common doxygen libxerces-c-devel xsd rpm-build
- name: Build
run: |
cd build
make -j `nproc`
make test
- name: Configure cmake
run: mkdir build && cd build && cmake -DCMAKE_C_COMPILER=`which gcc` -DCMAKE_CXX_COMPILER=`which g++` -DCMAKE_MAKE_PROGRAM=`which make` ..
- name: Make software
run: cd build && make -j `nproc`
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

View File

@ -1,29 +1,55 @@
name: GPUI CI
name: gpui-ci
on: [ push, pull_request ]
on:
workflow_dispatch:
workflow_call:
push:
branches: [ "*" ]
pull_request:
types: [ opened, synchronize, ready_for_review ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
name: Build software using docker
gpui-build-container:
uses: ./.github/workflows/build-container.yml
secrets: inherit
strategy:
matrix:
alt-version: [ { dist: "alt:p10", artifact: "p10" } ]
architecture: [ amd64 ]
os: [ { distr: "alt:sisyphus", artifact: "sisyphus" } ]
architecture: [ amd64, i386 ]
with:
distr: ${{ matrix.os.distr }}
architecture: ${{ matrix.architecture }}
steps:
- name: Checkout
uses: actions/checkout@v2
gpui-build:
uses: ./.github/workflows/build.yml
needs: [ gpui-build-container ]
secrets: inherit
strategy:
matrix:
os: [ { distr: "alt:sisyphus", artifact: "sisyphus" } ]
architecture: [ amd64, i386 ]
fail-fast: false
with:
artifact: ${{ matrix.os.artifact }}
architecture: ${{ matrix.architecture }}
- run: docker build . --file Dockerfile --tag build-environment --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) --build-arg DISTR=${{ matrix.alt-version.dist }} --build-arg ARCH=${{ matrix.architecture }}
gpui-test:
uses: ./.github/workflows/test.yml
needs: [ gpui-build-container ]
secrets: inherit
strategy:
matrix:
cpp-compiler: [ "gcc", "clang" ]
fail-fast: false
with:
architecture: "amd64"
cpp-compiler: ${{ matrix.cpp-compiler }}
- if: ${{ matrix.architecture == 'i386' }}
run: docker run --privileged=true -i --log-driver=none -a stdin -a stdout -a stderr -v "$(pwd)":/app build-environment --platform linux/i386
- if: ${{ matrix.architecture == 'amd64' }}
run: docker run --privileged=true -i --log-driver=none -a stdin -a stdout -a stderr -v "$(pwd)":/app build-environment
- uses: actions/upload-artifact@v2
with:
name: gpui-${{ matrix.alt-version.artifact }}-${{ matrix.architecture }}
path: RPMS/
gpui-publish-api-docs:
uses: ./.github/workflows/publish-api-docs.yml
needs: [ gpui-build, gpui-test ]
secrets: inherit

View File

@ -1,42 +1,39 @@
name: publish-api-doc
name: gpui-publish-api-doc
on:
push:
branches:
- master
on: [ workflow_call, workflow_dispatch ]
jobs:
api-doc:
gpui-publish-api-doc:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Git Checkout
uses: actions/checkout@v2
- name: Git Checkout
uses: actions/checkout@v3
- name: Create clean documentation branch
run: git checkout -b documentation
- name: Create clean documentation branch
run: git checkout -b documentation
- name: Install doxygen
run: sudo apt-get install doxygen
- name: Install doxygen
run: sudo apt-get install doxygen
- name: Generate autodocs for gpui editor
run: doxygen
- name: Generate autodocs for gpui editor
run: doxygen
- name: Add generated autodocs to Git repo in the documentation branch
run: |
git config --global user.email "gpui-github-bot@basealt.ru"
git config --global user.name "$GITHUB_WORKFLOW GitHub action"
git add -f docs
git commit -am "docs: add auto-generated developer documentation"
- name: Add generated autodocs to Git repo in the documentation branch
run: |
git config --global user.email "gpui-github-bot@basealt.ru"
git config --global user.name "$GITHUB_WORKFLOW GitHub action"
git add -f docs
git commit -am "docs: add auto-generated developer documentation"
- name: Publish autodocs as GitHub pages
run: git push -f origin documentation:documentation
- name: Result URLs
run: |
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 1)
REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 2)
echo "Documentation on a github.io: https://$REPO_OWNER.github.io/$REPO_NAME/docs"
echo ""
echo "Documentation branch: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/tree/documentation"
- name: Publish autodocs as GitHub pages
run: git push -f origin documentation:documentation
- name: Result URLs
run: |
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 1)
REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 2)
echo "Documentation on a github.io: https://$REPO_OWNER.github.io/$REPO_NAME/docs"
echo ""
echo "Documentation branch: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/tree/documentation"

42
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,42 @@
name: gpui-test
on:
workflow_call:
inputs:
architecture:
description: "Architecture"
type: string
required: true
cpp-compiler:
description: "C++ compiler"
type: "string"
default: "gcc"
jobs:
gpui-test:
runs-on: ubuntu-20.04
container: ghcr.io/${{ github.repository }}-${{ inputs.architecture }}:latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Test Clang
if: inputs.cpp-compiler == 'clang'
env:
QT_QPA_PLATFORM: offscreen
run: |
CXX=clang++ cmake -B build -DCMAKE_BUILD_TYPE:STRING=Debug -DGPUI_BUILD_TESTS:BOOL=ON .
cd build
make -j `nproc`
make test
- name: Test GCC
if: inputs.cpp-compiler != 'clang'
env:
QT_QPA_PLATFORM: offscreen
run: |
cmake -B build -DCMAKE_BUILD_TYPE:STRING=Debug -DGPUI_BUILD_TESTS:BOOL=ON .
cd build
make -j `nproc`
make test

13
.gitignore vendored
View File

@ -75,6 +75,19 @@ compile_commands.json
# Qt Qml cache
*_qmlcache.qrc
# VSCode Settings
.vscode/
# Build directory
build/
docs/
# Generated files
src/plugins/preferences/schemas/*.cpp
src/plugins/preferences/schemas/*.h
src/plugins/cmtl/schema/*.cpp
src/plugins/cmtl/schema/*.h
src/plugins/cmtx/schema/*.cpp
src/plugins/cmtx/schema/*.h
*.translations.qrc
src/core/version.h

View File

@ -1,15 +1,28 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.14)
project(GPUI)
set(CMAKE_CXX_STANDARD 17)
set(GPUI_VERSION_MAJOR 0)
set(GPUI_VERSION_MINOR 1)
execute_process(
COMMAND
bash -c "grep 'Version:' .gear/gpui.spec | awk -F ':' '{ print $2 }' | tr -d [:space:]"
OUTPUT_VARIABLE GPUI_GEAR_VERSION
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
string(REPLACE "." ";" GEAR_VERSION_LIST ${GPUI_GEAR_VERSION})
list(GET GEAR_VERSION_LIST 0 GPUI_VERSION_MAJOR)
list(GET GEAR_VERSION_LIST 1 GPUI_VERSION_MINOR)
list(GET GEAR_VERSION_LIST 2 GPUI_VERSION_PATCH)
set(CMAKE_MODULE_PATH ${GPUI_SOURCE_DIR}/cmake)
set(GPUI_DIR "${CMAKE_BINARY_DIR}")
include(TranslationUtils)
include(FindXsd)
include(FindLdap)
include(XsdUtils)
include(CheckCXXCompilerFlag)
if(UNIX)
include(GNUInstallDirs)

View File

@ -21,9 +21,44 @@ RUN apt-get update \
rpm-macros-generic-compat \
apt-repo \
apt-repo-tools \
cmake \
rpm-macros-cmake \
cmake-modules \
gcc-c++ \
clang15.0 \
qt5-base-devel \
qt5-declarative-devel \
qt5-tools-devel \
libsmbclient-devel \
libsmbclient \
qt5-base-common \
doxygen \
samba-devel \
catch2-devel \
libldap-devel \
libsasl2-devel \
libuuid-devel \
glib2-devel \
libpcre-devel \
libkrb5-devel \
libxerces-c-devel \
libgtest-devel \
xsd \
boost-devel-headers \
desktop-file-utils \
ImageMagick-tools \
libqt-mvvm-devel \
xorg-xvfb \
xvfb-run \
sudo \
ctest \
ragel \
&& export CURRENT_PWD=`pwd` \
&& groupadd --gid $GROUP_ID builder2 \
&& if [ $(getent group $GROUP_ID) ]; then \
echo "group $GROUP_ID exists."; \
else \
groupadd --gid $GROUP_ID builder2; \
fi \
&& useradd --uid $USER_ID --gid $GROUP_ID -ms /bin/bash builder2 \
&& groupadd sudo \
&& usermod -aG rpm builder2 \
@ -31,18 +66,19 @@ RUN apt-get update \
&& usermod -aG sudo builder2 \
&& echo "root ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers \
&& echo "builder2 ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers \
&& hasher-useradd builder2 \
&& hasher-useradd builder2 || : \
&& mkdir /app \
&& chown root:builder2 /app
&& chown $USER_ID:$GROUP_ID /app
# Copies your code file from your action repository to the filesystem path `/` of the container
COPY script/build.sh /build.sh
ARG ARCH
RUN chmod a=rwx,u+t /tmp
ARG ARCH
RUN if [ "$ARCH" = "i386" ]; then \
sed -i 's/gear-hsh/i586 gear-hsh/g' /build.sh; \
sed -i 's/x86_64/i686/g' /build.sh; \
sed -i 's/gear-rpm -ba/gear-rpm -ba --target=i386/g' build.sh; \
fi
USER builder2

View File

@ -1,19 +1,25 @@
# Building and installing on ALT-Linux
# Build dependencies
On ALT-Linux distributions all build dependencies can be installed with following command:
All build dependencies can be installed with following command:
```
apt-get install cmake gcc-c++ qt5-base-devel qt5-tools-devel qt5-base-common libxerces-c-devel xsd
apt-get install cmake rpm-macros-cmake cmake-modules gcc-c++ qt5-base-devel qt5-declarative-devel qt5-tools-devel libsmbclient-devel libsmbclient samba-devel libldap-devel libsasl2-devel libsmbclient-devel libuuid-devel glib2-devel libpcre-devel libkrb5-devel qt5-base-common doxygen libxerces-c-devel xsd boost-devel-headers desktop-file-utils ImageMagick-tools libqt-mvvm-devel xorg-xvfb xvfb-run
```
# Building with CMake and Make
After that GPUI can be built like so:
```
mkdir -p build
cmake -B build -DGPUI_BUILD_TESTS=OFF .
cd build && make -j `nproc`
cd build
make -j `nproc`
```
## ADMX
To use GPUI with ADMX policies, you need to also install them like so:
```
apt-get install admx-msi-setup
admx-msi-setup
```

View File

@ -1,9 +1,27 @@
## GPUI
![build workflow](https://github.com/august-alt/gpui/actions/workflows/main.yml/badge.svg)
![tests workflow](https://github.com/august-alt/gpui/actions/workflows/test.yml/badge.svg)
GPUI - is an open source utility for group policy management.
# GPUI
## Installation and Usage
GPUI — is an open source utility for group policy management on ALT-Linux.
Refer to the included INSTALL.md file for directions of how to compile, install, and
use the GPUI.
![Screenshot](https://github.com/mchernigin/gpui/assets/59616661/951b3715-96f0-4c8f-b044-33ab4b94a75f)
## Building and installation
For building and installation instructions refer to [INSTALL.md](INSTALL.md).
## Basic usage
```
Usage: gpui-main [options]
Options:
-p <path> The full path of policy to edit.
-b <path> The full path of policy bundle to load.
-h, --help Displays help on commandline options.
-n <name> This options left for compatibility with ADMC. Currently it
does nothing.
-v, --version Displays version information.
```

63
cmake/FindLdap.cmake Normal file
View File

@ -0,0 +1,63 @@
# Finds LDAP C Libraries
#
# Defined vars:
# Ldap_FOUND
# Ldap_INCLUDE_DIRS
#
# Imported targets:
# Ldap::Ldap
find_path(LDAP_INCLUDE_DIR
NAMES ldap.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
)
find_library(LDAP_LIBRARY ldap)
find_path(LBER_INCLUDE_DIR
NAMES lber.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
)
find_library(LBER_LIBRARY lber)
mark_as_advanced(
LDAP_INCLUDE_DIR
LBER_INCLUDE_DIR
LDAP_LIBRARY
LBER_LIBRARY
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Ldap
FOUND_VAR Ldap_FOUND
REQUIRED_VARS
LDAP_INCLUDE_DIR
LBER_INCLUDE_DIR
LDAP_LIBRARY
LBER_LIBRARY
)
if(Ldap_FOUND)
set(Ldap_INCLUDE_DIRS ${LDAP_INCLUDE_DIR} ${LBER_INCLUDE_DIR})
list(REMOVE_DUPLICATES Ldap_INCLUDE_DIRS)
endif()
if(Ldap_FOUND AND NOT TARGET Ldap::Ldap)
add_library(Ldap::Ldap INTERFACE IMPORTED)
target_link_libraries(Ldap::Ldap
INTERFACE
ldap
lber
)
target_include_directories(Ldap::Ldap
INTERFACE
${Ldap_INCLUDE_DIRS}
)
endif()

54
cmake/FindXsd.cmake Normal file
View File

@ -0,0 +1,54 @@
# Locate Xsd from code synthesis include paths and binary
# Xsd can be found at http://codesynthesis.com/products/xsd/
# Written by Frederic Heem, frederic.heem _at_ telsey.it
# This module defines
# XSD_INCLUDE_DIR, where to find elements.hxx, etc.
# XSD_EXECUTABLE, where is the xsd compiler
# XSD_FOUND, If false, don't try to use xsd
FIND_PATH( XSD_INCLUDE_DIR xsd/cxx/parser/elements.hxx
"/opt/local/xsd-3.3.0-i686-macosx/libxsd"
"C:/Programs/xsd-3.3.0/libxsd"
"C:/Program Files/CodeSynthesis XSD 3.2/include"
"C:/mingw/xsd-3.3.0-i686-windows/libxsd"
$ENV{XSDDIR}/include
$ENV{CODESYNTH}/include
/usr/local/include /usr/include
$ENV{XSDDIR}/libxsd
)
IF( WIN32 )
SET( XSDCXX_FILENAME1 xsd-cxx.exe )
ELSE( )
SET( XSDCXX_FILENAME1 xsdcxx )
SET( XSDCXX_FILENAME2 xsd )
ENDIF( )
FIND_PROGRAM( XSDCXX_EXECUTABLE
NAMES
${XSDCXX_FILENAME1} ${XSDCXX_FILENAME2}
PATHS
"/opt/local/xsd-3.3.0-i686-macosx/bin"
"C:/Programs/xsd-3.3.0/bin"
"C:/mingw/xsd-3.3.0-i686-windows/bin"
"C:/Program Files/CodeSynthesis XSD 3.2/bin"
$ENV{XSDDIR}/bin
/usr/local/bin
/usr/bin
$ENV{XSDDIR}/xsd
)
MESSAGE(STATUS ${XSDCXX_EXECUTABLE})
# if the include and the program are found then we have it
IF( XSD_INCLUDE_DIR )
IF( XSDCXX_EXECUTABLE )
SET( XSD_FOUND "YES" )
ENDIF( XSDCXX_EXECUTABLE )
ENDIF( XSD_INCLUDE_DIR )
MARK_AS_ADVANCED(
XSD_INCLUDE_DIR
XSDCXX_EXECUTABLE
)

View File

@ -9,6 +9,8 @@ set(GPUI_LIBRARY_DIR @CMAKE_INSTALL_PREFIX@/lib)
# set GPUI_LIBRARY variables
set(GPUI_GUI_LIBRARY gpui-gui)
set(GPUI_IO_LIBRARY gpui-io)
set(GPUI_MODEL_LIBRARY gpui-model)
set(GPUI_CORE_LIBRARY gpui-core)
set(GPUI_LDAP_LIBRARY gpui-ldap)
set(GPUI_LIBRARIES ${GPUI_GUI_LIBRARY} ${GPUI_IO_LIBRARY} ${GPUI_CORE_LIBRARY} ${GPUI_LDAP_LIBRARY})
set(GPUI_LIBRARIES ${GPUI_GUI_LIBRARY} ${GPUI_IO_LIBRARY} ${GPUI_MODEL_LIBRARY})

View File

@ -1,6 +1,6 @@
function(add_translation_resource out_file)
function(add_translation_resource out_file prefix)
set(qm_files ${ARGN})
set(resource ${CMAKE_CURRENT_SOURCE_DIR}/translations.qrc)
set(resource ${CMAKE_CURRENT_SOURCE_DIR}/${prefix}.translations.qrc)
file(WRITE ${resource} "<!DOCTYPE RCC><RCC version=\"1.0\">\n <qresource prefix=\"/\">\n")
foreach(LANG ${qm_files})
@ -11,3 +11,20 @@ function(add_translation_resource out_file)
set(${out_file} ${resource} PARENT_SCOPE)
endfunction()
function(add_translation out_files)
set(qm_files "")
foreach(filename ${ARGN})
get_filename_component(basename ${filename} NAME_WE)
set(qm "${CMAKE_CURRENT_SOURCE_DIR}/${basename}.qm")
add_custom_command(
OUTPUT "${qm}"
COMMAND "${Qt5_LRELEASE_EXECUTABLE}"
ARGS -markuntranslated "Is not translated!" -nounfinished -removeidentical -compress "${filename}" -qm "${qm}"
DEPENDS "${filename}" VERBATIM
)
list(APPEND qm_files "${qm}")
endforeach()
set(${out_files} ${qm_files} PARENT_SCOPE)
endfunction()

45
cmake/XsdUtils.cmake Normal file
View File

@ -0,0 +1,45 @@
cmake_policy(SET CMP0071 NEW)
function(add_xsd_library library_name)
set(XSD_FILES ${ARGN})
foreach(FILE ${XSD_FILES})
string(REGEX REPLACE "[.]xsd" ".h" HEADER ${FILE})
set(XSD_HEADERS ${XSD_HEADERS} ${HEADER})
endforeach()
foreach(FILE ${XSD_FILES})
string(REGEX REPLACE "[.]xsd" ".cpp" SOURCE ${FILE})
set(XSD_SOURCES ${XSD_SOURCES} ${SOURCE})
endforeach()
set(OUT_FILES
${XSD_HEADERS}
${XSD_SOURCES}
)
set(XSD_FLAGS cxx-tree
--generate-doxygen
--generate-ostream
--generate-serialization
--generate-polymorphic
--polymorphic-type-all
--generate-wildcard
--cxx-suffix .cpp
--hxx-suffix .h
--std c++11
--type-naming ucc
--root-element-all
)
add_custom_command(
OUTPUT ${OUT_FILES}
COMMAND ${XSDCXX_EXECUTABLE} ${XSD_FLAGS} ${XSD_FILES}
DEPENDS ${XSD_FILES}
COMMENT "Running ${XSDCXX_EXECUTABLE} ${XSD_FLAGS} ${XSD_FILES}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND_EXPAND_LISTS
)
add_library(${library_name} STATIC ${OUT_FILES})
endfunction()

View File

@ -1,13 +1,4 @@
#!/bin/bash -ex
chown -R builder2:builder2 /app/
mkdir -p /app/RPMS/
mkdir /home/builder2/hasher
mkdir /home/builder2/.hasher
cp /app/hasher/config /home/builder2/.hasher/config
hsh --initroot-only --no-wait-lock -vv /home/builder2/hasher
cd /app/ && gear --hasher -- hsh-rebuild /home/builder2/hasher
cp /home/builder2/hasher/repo/x86_64/RPMS.hasher/*.rpm /app/RPMS/
chown -R builder2 /app/
cd /app/ && gear-rpm -ba

View File

@ -31,10 +31,10 @@ Name[zh_TW]=GPUI
GenericName=GPUI
GenericName[ru]=Редактор групповых политик
X-GNOME-FullName=GPUI
Comment=Group Policy Editor
Comment[ru]=Редактор групповых политик
Comment=Group Policy Editor allows user to edit group policy templates
Comment[ru]=Редактор групповых политик позволяет редактировать шаблоны групповых политик
Exec=gpui-main
Terminal=false
Type=Application
Categories=System;
Categories=System;FileTools;
Icon=gpui

58
setup/man/en/gpui.1 Normal file
View File

@ -0,0 +1,58 @@
.\" Manpage for gpui.
.\" Contact august@altlinux.org to correct errors or typos.
.TH man 1 "10 Nov 2022" "0.2.17" "gpui man page"
.SH NAME
gpui-main \- manage group policy templates
.SH SYNOPSIS
gpui-main [-p policy path] [-b admx path] [-n name of a policy] [-h | --help] [-v | --version]
.SH DESCRIPTION
gpui-main is a program for managing group policy templates.
.SH OPTIONS
.TP
.if !'po4a'hide' .BR \-p
Provide the full path of the policy to edit.
.TP
.if !'po4a'hide' .BR \-b
Provide the path of admx files to load.
.TP
.if !'po4a'hide' .BR \-n
Parameters provides compatibilty with ADMC, currently it performs no specific function.
.TP
.if !'po4a'hide' .BR \-\-log\-console
Set log level for console. By default: "none".
.TP
.if !'po4a'hide' .BR \-\-log\-syslog
Set log level for syslog. By default: "none".
.TP
.if !'po4a'hide' .BR \-\-log\-file
Set log level for file in ~/.local/share/gpui/. By default: "warning".
.TP
.if !'po4a'hide' .BR \-h ", " \-\-help
Show help message and exit program.
.TP
.if !'po4a'hide' .BR \-v ", " \-\-version
Show version information.
.SH LOG LEVELS
.TP
.if !'po4a'hide' .BR "none"
Disable logging.
.TP
.if !'po4a'hide' .BR "debug"
Log debug messages and higher.
.TP
.if !'po4a'hide' .BR "info"
Log info messages and higher.
.TP
.if !'po4a'hide' .BR "warning"
Log warning messages and higher.
.TP
.if !'po4a'hide' .BR "critical"
Log critical messages and higher.
.TP
.if !'po4a'hide' .BR "fatal"
Log fatal messages and higher.
.SH SEE ALSO
.SH BUGS
Utility in a state of active development and may contain unspecified number of various bugs.
.SH AUTHOR
August (august@altlinux.org)

58
setup/man/ru/gpui.1 Normal file
View File

@ -0,0 +1,58 @@
.\" Manpage for gpui.
.\" Contact august@altlinux.org to correct errors or typos.
.TH man 1 "29 Aug 2023" "0.2.32" "gpui man page"
.SH NAME
gpui-main \- редактирует шаблоны групповых политик
.SH SYNOPSIS
gpui-main [-p путь к политике] [-b путь к admx файлам] [-n имя политики для отображения] [-h | --help] [-v | --version]
.SH DESCRIPTION
gpui-main это программа для управления шаблонами групповой политики.
.SH OPTIONS
.TP
.if !'po4a'hide' .BR \-p
Позволяет указать путь к шаблону групповой политики, который нужно редактировать.
.TP
.if !'po4a'hide' .BR \-b
Позволяет указать путь для загрузки admx файлов.
.TP
.if !'po4a'hide' .BR \-n
Параметр оставлен для обеспечения обраной совместимости с ADMC. Он никак не влияет на работу приложения.
.TP
.if !'po4a'hide' .BR \-\-log\-console
Установить уровень логирования для консоли. По умолчанию: "none".
.TP
.if !'po4a'hide' .BR \-\-log\-syslog
Установить уровень логирования для syslog. По умолчанию: "none".
.TP
.if !'po4a'hide' .BR \-\-log\-file
Установить уровень логирования для файла в ~/.local/share/gpui/. По умолчанию: "warning".
.TP
.if !'po4a'hide' .BR \-h ", " \-\-help
Показать справочное сообщение и закончить работу.
.TP
.if !'po4a'hide' .BR \-v ", " \-\-version
Показать информацию о версии.
.SH LOG LEVELS
.TP
.if !'po4a'hide' .BR "none"
Отключить логирование.
.TP
.if !'po4a'hide' .BR "debug"
Логировать сообщения уровня debug и выше.
.TP
.if !'po4a'hide' .BR "info"
Логировать сообщения уровня info и выше.
.TP
.if !'po4a'hide' .BR "warning"
Логировать сообщения уровня warning и выше.
.TP
.if !'po4a'hide' .BR "critical"
Логировать сообщения уровня critical и выше.
.TP
.if !'po4a'hide' .BR "fatal"
Логировать сообщения уровня fatal.
.SH SEE ALSO
.SH BUGS
Утилита находится в состоянии активной разработки и может содержать неопределенное количество различных ошибок.
.SH AUTHOR
August (august@altlinux.org)

View File

@ -1,6 +1,20 @@
# set compiler options
if (CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undef -fvisibility=hidden -fvisibility-inlines-hidden -pedantic -Wall -Wextra -Wno-long-long")
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "e2k")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undef -fvisibility=default -pedantic -Wall")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undef -fvisibility=hidden -fvisibility-inlines-hidden -pedantic -Wall\
-Wextra -Wno-long-long -Weffc++ -Werror -Wall -Wextra -pedantic -Wcast-align -Wcast-qual -Wctor-dtor-privacy \
-Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wnoexcept -Wold-style-cast \
-Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-null-sentinel -Wundef \
-Wno-unused -Wno-variadic-macros -Wno-parentheses -Wnonnull -fdiagnostics-show-option")
if(CMAKE_SIZEOF_VOID_P LESS_EQUAL 4)
CHECK_CXX_COMPILER_FLAG("-march=i586" COMPILER_SUPPORTS_MARCH_I586)
if (${COMPILER_SUPPORTS_MARCH_I586})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i586")
endif()
endif()
endif()
endif()
macro(add_gpui_library name)
@ -21,7 +35,8 @@ macro(add_gpui_library name)
endmacro(add_gpui_library)
add_subdirectory(app)
add_subdirectory(core)
add_subdirectory(gui)
add_subdirectory(io)
add_subdirectory(model)
add_subdirectory(plugins)
add_subdirectory(ldap)

View File

@ -18,15 +18,32 @@
**
***********************************************************************************************************************/
#include "../core/compositesnapindetailsdialog.h"
#include "../core/logger/prelude.h"
#include "../core/pluginstorage.h"
#include "../core/snapindetailsdialog.h"
#include "../core/snapindetailsfactory.h"
#include "../core/snapinloader.h"
#include "../core/snapinmanager.h"
#include "../core/translatorstorage.h"
#include "../core/version.h"
#include "../gui/commandlineparser.h"
#include "../gui/mainwindow.h"
#include "../model/pluginstorage.h"
#include <iostream>
#include <QApplication>
int main(int argc, char ** argv) {
// Load plugins.
gpui::PluginStorage::instance()->loadDefaultPlugins();
int main(int argc, char **argv)
{
// Register types for factory.
gpui::SnapInDetailsFactory::define<gpui::SnapInDetailsDialog>("ISnapIn");
gpui::SnapInDetailsFactory::define<gpui::CompositeSnapInDetailsDialog>("ICompositeSnapIn");
// Load plugins and snap-ins.
auto snapInManager = std::make_unique<gpui::SnapInManager>();
auto snapInLoader = std::make_unique<gpui::SnapInLoader>(snapInManager.get());
snapInLoader->loadDefaultSnapIns();
// Create window.
QApplication app(argc, argv);
@ -36,41 +53,51 @@ int main(int argc, char ** argv) {
app.setOrganizationName(QCoreApplication::translate("main", "BaseALT Ltd."));
app.setOrganizationDomain("basealt.ru");
app.setApplicationName("GPUI");
app.setApplicationVersion("0.2.0");
gpui::CommandLineParser parser(app);
gpui::CommandLineOptions options;
QString errorMessage;
gpui::CommandLineParser::CommandLineParseResult parserResult = parser.parseCommandLine(&options, &errorMessage);
app.setApplicationVersion(getApplicationVersion());
QLocale locale;
std::unique_ptr<QTranslator> qtTranslator = std::make_unique<QTranslator>();
qtTranslator->load(locale, "gui", "_", ":/");
std::unique_ptr<QTranslator> qtTranslator2 = std::make_unique<QTranslator>();
qtTranslator2->load(QString("qt_").append(QLocale::system().name()),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
QCoreApplication::installTranslator(qtTranslator.get());
QCoreApplication::installTranslator(qtTranslator2.get());
QString language = locale.system().name().split("_").at(0);
TranslatorStorage translatorStorage;
translatorStorage.loadTranslators(language);
translatorStorage.loadQtTranslations(language, "qt_");
gpui::CommandLineParser parser(app);
gpui::CommandLineOptions options{};
QString errorMessage{};
gpui::CommandLineParser::CommandLineParseResult parserResult = parser.parseCommandLine(&options, &errorMessage);
switch (parserResult)
{
case gpui::CommandLineParser::CommandLineError:
printf("%s \n", qPrintable(errorMessage));
parser.showHelp();
return 1;
std::cerr << qPrintable(errorMessage) << std::endl;
parser.showHelp(1); // NOTE: Exits with 1
case gpui::CommandLineParser::CommandLineHelpRequested:
parser.showHelp();
return 0;
parser.showHelp(0); // NOTE: Exits with 0
case gpui::CommandLineParser::CommandLineVersionRequested:
parser.showVersion();
return 0;
parser.showVersion(); // NOTE: Exits with 0
case gpui::CommandLineParser::CommandLineOk:
default:
break;
}
gpui::MainWindow window(options);
auto logManager = gpui::logger::LoggerManager::globalInstance();
if (options.consoleLogLevel != LOG_LEVEL_DISABLED)
{
logManager->addLogger<gpui::logger::ConsoleLogger>(options.consoleLogLevel);
}
if (options.consoleLogLevel != LOG_LEVEL_DISABLED)
{
logManager->addLogger<gpui::logger::SyslogLogger>(options.syslogLogLevel);
}
if (options.consoleLogLevel != LOG_LEVEL_DISABLED)
{
logManager->addLogger<gpui::logger::FileLogger>(options.fileLogLevel);
}
gpui::MainWindow window(options, snapInManager.get(), &translatorStorage);
window.show();
return app.exec();

28
src/core/CMakeLists.txt Normal file
View File

@ -0,0 +1,28 @@
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
${CMAKE_CURRENT_SOURCE_DIR}/version.h)
file(GLOB HEADERS "*.h")
file(GLOB SOURCES "*.cpp")
file(GLOB UIFORMS "*.ui")
set(SOURCES ${HEADERS} ${SOURCES} ${UIFORMS})
add_definitions(
-DGPUI_CORE_LIBRARY
)
add_gpui_library(gpui-core ${SOURCES})
add_subdirectory(logger)
target_link_libraries(gpui-core gpui-logger)
target_link_libraries(gpui-core Qt5::Core Qt5::Gui Qt5::Widgets)

View File

@ -0,0 +1,65 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "abstractcompositesnapin.h"
#include <QMap>
#include <QString>
#include <QVersionNumber>
namespace gpui
{
class AbstractCompositeSnapInPrivate
{
public:
QMap<QString, QVersionNumber> dependencies{};
};
QMap<QString, QVersionNumber> AbstractCompositeSnapIn::getDependencies() const
{
return d->dependencies;
}
AbstractCompositeSnapIn::AbstractCompositeSnapIn(QString type,
QString name,
QString helpText,
QVersionNumber version,
QString license,
QString copyright)
: AbstractSnapIn(type, name, helpText, version, license, copyright)
, d(new AbstractCompositeSnapInPrivate())
{}
AbstractCompositeSnapIn::~AbstractCompositeSnapIn()
{
delete d;
}
void AbstractCompositeSnapIn::addDependency(const QString &name, const QVersionNumber &version)
{
d->dependencies.insert(name, version);
}
void AbstractCompositeSnapIn::removeDependency(const QString &name)
{
d->dependencies.remove(name);
}
} // namespace gpui

View File

@ -0,0 +1,65 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 _ABSTRACTCOMPOSITESNAPIN_H
#define _ABSTRACTCOMPOSITESNAPIN_H
#include "core.h"
#include "icompositesnapin.h"
#include "abstractsnapin.h"
namespace gpui
{
class AbstractCompositeSnapInPrivate;
class GPUI_CORE_EXPORT AbstractCompositeSnapIn : public ICompositeSnapIn, public AbstractSnapIn
{
public:
QMap<QString, QVersionNumber> getDependencies() const override final;
protected:
AbstractCompositeSnapIn(QString type,
QString name,
QString helpText = {},
QVersionNumber version = {},
QString license = {},
QString copyright = {});
~AbstractCompositeSnapIn();
protected:
void addDependency(const QString &name, const QVersionNumber &version);
void removeDependency(const QString &name);
private:
AbstractCompositeSnapIn(const AbstractCompositeSnapIn &) = delete; // copy ctor
AbstractCompositeSnapIn(AbstractCompositeSnapIn &&) = delete; // move ctor
AbstractCompositeSnapIn &operator=(const AbstractCompositeSnapIn &) = delete; // copy assignment
AbstractCompositeSnapIn &operator=(AbstractCompositeSnapIn &&) = delete; // move assignment
private:
AbstractCompositeSnapInPrivate *d;
};
} // namespace gpui
#endif //_ABSTRACTCOMPOSITESNAPIN_H

131
src/core/abstractsnapin.cpp Normal file
View File

@ -0,0 +1,131 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "abstractsnapin.h"
#include <qstandarditemmodel.h>
namespace gpui
{
class AbstractSnapInPrivate
{
public:
QString name{};
QUuid id{};
QAbstractItemModel *rootNode{nullptr};
QString type{};
QString helpText{};
QVersionNumber version{};
QString license{};
QString copyright{};
};
QUuid AbstractSnapIn::getId() const
{
return d->id;
}
QAbstractItemModel *AbstractSnapIn::getRootNode() const
{
return d->rootNode;
}
QString AbstractSnapIn::getDisplayName() const
{
return d->name;
}
QString AbstractSnapIn::getType() const
{
return d->type;
}
QString AbstractSnapIn::getHelpText() const
{
return d->helpText;
}
QVersionNumber AbstractSnapIn::getVersion() const
{
return d->version;
}
QString AbstractSnapIn::getLicense() const
{
return d->license;
}
QString AbstractSnapIn::getCopyright() const
{
return d->copyright;
}
AbstractSnapIn::AbstractSnapIn(QString type,
QString name,
QString helpText,
QVersionNumber version,
QString license,
QString copyright)
: d(new AbstractSnapInPrivate())
{
d->name = name;
d->type = type;
d->helpText = helpText;
d->version = version;
d->license = license;
d->copyright = copyright;
}
AbstractSnapIn::~AbstractSnapIn()
{
delete d;
}
void AbstractSnapIn::setId(QUuid id)
{
d->id = id;
}
void AbstractSnapIn::setRootNode(QAbstractItemModel *rootNode)
{
d->rootNode = rootNode;
}
void AbstractSnapIn::setHelpText(QString text)
{
d->helpText = text;
}
void AbstractSnapIn::setVersion(QVersionNumber version)
{
d->version = version;
}
void AbstractSnapIn::setLicense(QString license)
{
d->license = license;
}
void AbstractSnapIn::setCopyright(QString copyright)
{
d->copyright = copyright;
}
} // namespace gpui

93
src/core/abstractsnapin.h Normal file
View File

@ -0,0 +1,93 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 _ABSTRACTSNAPIN_H
#define _ABSTRACTSNAPIN_H
#include "core.h"
#include "isnapin.h"
#include "plugin.h"
#include <QAbstractItemModel>
#include <QUuid>
#include <QVersionNumber>
namespace gpui
{
class AbstractSnapInPrivate;
/**
* @brief Adapts interface of a ISnapIn for a plugin.
*/
class GPUI_CORE_EXPORT AbstractSnapIn : public virtual ISnapIn
{
public:
QUuid getId() const override;
QString getType() const override;
QAbstractItemModel *getRootNode() const override;
QString getDisplayName() const override;
QString getHelpText() const override;
QVersionNumber getVersion() const override;
QString getLicense() const override;
QString getCopyright() const override;
protected:
AbstractSnapIn(QString type,
QString name,
QString helpText = {},
QVersionNumber version = {},
QString license = {},
QString copyright = {});
~AbstractSnapIn();
protected:
void setId(QUuid id);
void setRootNode(QAbstractItemModel *rootNode);
void setHelpText(QString text);
void setVersion(QVersionNumber version);
void setLicense(QString license);
void setCopyright(QString copyright);
private:
AbstractSnapIn(const AbstractSnapIn &) = delete; // copy ctor
AbstractSnapIn(AbstractSnapIn &&) = delete; // move ctor
AbstractSnapIn &operator=(const AbstractSnapIn &) = delete; // copy assignment
AbstractSnapIn &operator=(AbstractSnapIn &&) = delete; // move assignment
private:
AbstractSnapInPrivate *d;
};
} // namespace gpui
#endif //_ABSTRACTSNAPIN_H

View File

@ -25,7 +25,13 @@
#define GPUI_SYMBOL_EXPORT __attribute__((__dllexport__))
#define GPUI_SYMBOL_IMPORT __attribute__((__dllimport__))
#else
#if defined (__LCC__)
#define GPUI_SYMBOL_EXPORT
#else
#define GPUI_SYMBOL_EXPORT __attribute__((__visibility__("default")))
#endif
#define GPUI_SYMBOL_IMPORT
#endif

View File

@ -0,0 +1,78 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "compositesnapindetailsdialog.h"
#include "ui_compositesnapindetailsdialog.h"
#include "icompositesnapin.h"
#include <QTableWidget>
namespace gpui
{
CompositeSnapInDetailsDialog::CompositeSnapInDetailsDialog(QWidget *parent,
::gpui::ISnapIn *snapIn)
: CompositeSnapInDetailsDialog(parent)
{
setSnapIn(snapIn);
}
CompositeSnapInDetailsDialog::CompositeSnapInDetailsDialog(QWidget *parent)
: ISnapInDetailsDialog(parent)
, ui(new Ui::CompositeSnapInDetailsDialog())
{
ui->setupUi(this);
}
CompositeSnapInDetailsDialog::~CompositeSnapInDetailsDialog()
{
delete ui;
}
void CompositeSnapInDetailsDialog::setSnapIn(ISnapIn *snapIn)
{
ui->snapInWidget->setSnapIn(snapIn);
auto compositeSnapIn = dynamic_cast<ICompositeSnapIn *>(snapIn);
if (compositeSnapIn)
{
QMapIterator<QString, QVersionNumber> iterator(compositeSnapIn->getDependencies());
int row = 0;
while (iterator.hasNext())
{
iterator.next();
QTableWidgetItem *nameItem = new QTableWidgetItem(iterator.key());
QTableWidgetItem *versionItem = new QTableWidgetItem(iterator.value().toString());
ui->tableWidget->insertRow(row);
ui->tableWidget->setItem(row, 0, nameItem);
ui->tableWidget->setItem(row, 1, versionItem);
++row;
}
}
}
} // namespace gpui

View File

@ -0,0 +1,62 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 _COMPOSITESNAPINDETAILSDIALOG_H
#define _COMPOSITESNAPINDETAILSDIALOG_H
#include "core.h"
#include "isnapin.h"
#include "isnapindetailsdialog.h"
namespace Ui
{
class CompositeSnapInDetailsDialog;
}
namespace gpui
{
/**
* @brief Shows properties and dependencies of composite snap-in.
*/
class GPUI_CORE_EXPORT CompositeSnapInDetailsDialog : public ISnapInDetailsDialog
{
Q_OBJECT
public:
CompositeSnapInDetailsDialog(QWidget *parent, ISnapIn *snapIn);
CompositeSnapInDetailsDialog(QWidget *parent = nullptr);
~CompositeSnapInDetailsDialog();
void setSnapIn(ISnapIn *snapIn) override;
private:
CompositeSnapInDetailsDialog(const CompositeSnapInDetailsDialog &) = delete; // copy ctor
CompositeSnapInDetailsDialog(CompositeSnapInDetailsDialog &&) = delete; // move ctor
CompositeSnapInDetailsDialog &operator=(const CompositeSnapInDetailsDialog &) = delete; // copy assignment
CompositeSnapInDetailsDialog &operator=(CompositeSnapInDetailsDialog &&) = delete; // move assignment
private:
Ui::CompositeSnapInDetailsDialog *ui;
};
} // namespace gpui
#endif //_COMPOSITESNAPINDETAILSDIALOG_H

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CompositeSnapInDetailsDialog</class>
<widget class="QDialog" name="CompositeSnapInDetailsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>419</width>
<height>572</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Dependencies:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QTableWidget" name="tableWidget">
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Version</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="::gpui::SnapInDetailsWidget" name="snapInWidget" native="true">
<property name="minimumSize">
<size>
<width>400</width>
<height>300</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Snap-In Details:</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>::gpui::SnapInDetailsWidget</class>
<extends>QWidget</extends>
<header>snapindetailswidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>clicked(QAbstractButton*)</signal>
<receiver>CompositeSnapInDetailsDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>209</x>
<y>550</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>285</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -18,7 +18,7 @@
**
***********************************************************************************************************************/
#include "model.h"
#include "core.h"
namespace gpui {

View File

@ -23,14 +23,13 @@
#include "common.h"
#ifdef GPUI_MODEL_LIBRARY
#define GPUI_MODEL_EXPORT GPUI_SYMBOL_EXPORT
#ifdef GPUI_CORE_LIBRARY
#define GPUI_CORE_EXPORT GPUI_SYMBOL_EXPORT
#else
#define GPUI_MODEL_EXPORT GPUI_SYMBOL_IMPORT
#define GPUI_CORE_EXPORT GPUI_SYMBOL_IMPORT
#endif
namespace gpui {
}
namespace gpui
{}
#endif // GPUI_MODEL_H

85
src/core/factory.h Normal file
View File

@ -0,0 +1,85 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 _FACTORY_H
#define _FACTORY_H
#include <map>
#include <memory>
#include <stdexcept>
namespace gpui
{
/**
* @brief Implementation of abstract factory pattern.
*/
template<typename Interface, typename TKey = std::string>
class Factory
{
public:
typedef TKey Key;
typedef std::unique_ptr<Interface> Type;
typedef Type (*ConcreteFactory)();
/**
* @brief define Defines new pair constructor and key if already not present.
* @param key Key of an element.
* @param value Factory that constructs the element.
* @return True on success.
*/
bool define(Key const &key, ConcreteFactory const &value)
{
return storage.insert(typename Storage::value_type(key, value)).second;
}
/**
* @brief create Creates element of given Type.
* @param key Key of element ot construct.
* @return Element of given type.
*/
Type create(Key const &key)
{
typename Storage::const_iterator i = storage.find(key);
if (i == storage.end())
{
throw std::invalid_argument(std::string(__PRETTY_FUNCTION__)
+ ": key is not registered!");
}
return i->second();
}
/**
* @brief
*/
template<class Base, class Actual>
static std::unique_ptr<Base> create_func()
{
return std::unique_ptr<Base>(new Actual());
}
private:
typedef std::map<Key, ConcreteFactory> Storage;
Storage storage{};
};
} // namespace gpui
#endif //_FACTORY_H

View File

@ -0,0 +1,41 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 _ICOMPOSITESNAPIN_H
#define _ICOMPOSITESNAPIN_H
#include "core.h"
#include "isnapin.h"
namespace gpui
{
/**
* @brief Composite snap-in requires list of dependencies to operate.
*/
class GPUI_CORE_EXPORT ICompositeSnapIn : public virtual ISnapIn
{
public:
virtual QMap<QString, QVersionNumber> getDependencies() const = 0;
};
} // namespace gpui
#endif //_ICOMPOSITESNAPIN_H

120
src/core/isnapin.h Normal file
View File

@ -0,0 +1,120 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 _ISNAPIN_H
#define _ISNAPIN_H
#include "core.h"
#include <QAbstractItemModel>
#include <QMainWindow>
#include <QUuid>
#include <QVersionNumber>
namespace gpui
{
/**
* @brief The ISnapIn interface is a base for all snap-ins in a system.
*/
class GPUI_CORE_EXPORT ISnapIn
{
public:
virtual ~ISnapIn() = default;
/**
* @brief Called when a snap-in is initialized.
* It allows derived classes to provide additional initialization.
*/
virtual void onInitialize(QMainWindow *mainWindow) = 0;
/**
* @brief onShutdown Called when the snap-in is shutting down.
* Once this call returns, actions which modify the application, such as adding nodes,
* or modifying view descriptions, are not honored.
*/
virtual void onShutdown() = 0;
/**
* @brief onDataLoad Called when snap-in loads data from policy folder.
* @param policyPath Path to load policy data from.
* @param locale Locale to use.
*/
virtual void onDataLoad(const std::string &policyPath, const std::string &locale) = 0;
/**
* @brief onDataSave Called when snap-in saves data.
*/
virtual void onDataSave() = 0;
/**
* @brief Gets the identifier for the instance of the snap-in.
* The identifier is unique across snap-in instances within a application.
*/
virtual QUuid getId() const = 0;
/**
* @brief getType Returns a type of a snap-in.
*/
virtual QString getType() const = 0;
/**
* @brief Gets the identifier for the instance of the snap-in.
* The identifier is unique across snap-in instances within a application.
* This value can never be a null value or invalid.
*/
virtual QAbstractItemModel *getRootNode() const = 0;
/**
* @brief getDisplayName Returns display name of a snap-in.
*/
virtual QString getDisplayName() const = 0;
/**
* @brief getHelpText Returns the help text for the instance of the snap-in.
* @return
*/
virtual QString getHelpText() const = 0;
/**
* @brief getVersion Returns version of a snap-in.
* @return
*/
virtual QVersionNumber getVersion() const = 0;
/**
* @brief getLicense Returns license assosiated with the snap-in.
*/
virtual QString getLicense() const = 0;
/**
* @brief getCopyright Returns copyright of snap-in.
*/
virtual QString getCopyright() const = 0;
/**
* @brief onRetranslateUI Retranslate UI
* @param locale locale to use in current snap-in.
*/
virtual void onRetranslateUI(const std::string &locale) = 0;
};
} // namespace gpui
#endif //_ISNAPIN_H

View File

@ -0,0 +1,49 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 _ISNAPINDETAILSDIALOG_H
#define _ISNAPINDETAILSDIALOG_H
#include "core.h"
#include <QDialog>
#include "isnapin.h"
namespace gpui
{
/**
* @brief Common interface for a details dialog.
*/
class GPUI_CORE_EXPORT ISnapInDetailsDialog : public QDialog
{
Q_OBJECT
public:
explicit ISnapInDetailsDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags())
: QDialog(parent, f)
{}
virtual void setSnapIn(ISnapIn *snapIn) = 0;
};
} // namespace gpui
#endif //_ISNAPINDETAILSDIALOG_H

67
src/core/isnapinmanager.h Normal file
View File

@ -0,0 +1,67 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 _ISNAPINMANAGER_H
#define _ISNAPINMANAGER_H
#include "core.h"
#include <vector>
#include "isnapin.h"
namespace gpui
{
/**
* @brief class ISnapInManager Manages all the snap-ins in an application.
*/
class GPUI_CORE_EXPORT ISnapInManager
{
public:
virtual ~ISnapInManager() = default;
/**
* @brief addSnapIn Adds a snap-in to the manager.
* @param snapIn Snap-In to add.
*/
virtual void addSnapIn(ISnapIn *snapIn) = 0;
//
/**
* @brief removeSnapIn Removes a snap-in from the manager.
* @param snapIn Snap-In to remove.
*/
virtual void removeSnapIn(ISnapIn *snapIn) = 0;
/**
* @brief getSnapIns Get a list of all snap-ins associated with this manager.
* @return List of all snap-ins.
*/
virtual std::vector<ISnapIn *> getSnapIns() const = 0;
/**
* @brief Unload all the snap-ins from the manager.
*/
virtual void clear() = 0;
};
} // namespace gpui
#endif //_ISNAPINMANAGER_H

View File

@ -0,0 +1,28 @@
find_package(Qt5 COMPONENTS Core REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(HEADERS
loggermanager.h
loggermessage.h
logger.h
consolelogger.h
filelogger.h
sysloglogger.h
)
set(SOURCES
loggermanager.cpp
logger.cpp
consolelogger.cpp
filelogger.cpp
sysloglogger.cpp
)
add_definitions(
-DGPUI_CORE_LIBRARY
)
add_library(gpui-logger STATIC ${SOURCES} ${HEADERS})
target_include_directories(gpui-logger PUBLIC ${Qt5Gui_INCLUDE_DIRS})
target_link_libraries(gpui-logger Qt5::Core)

View File

@ -0,0 +1,112 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "consolelogger.h"
#include <cstring>
#include <fstream>
#include <iostream>
#include <unistd.h>
/*!
* \brief checkColorSupport Checks if console supports colored output.
* \param fd File descriptor.
* \return True if console supports colored output.
*/
static bool checkColorSupport(int fd)
{
// TODO(mchernigin): use `tput colors`, and use method bellow only if `tput` returns !0
bool is_tty = isatty(fd);
const char *TERM = std::getenv("TERM");
return is_tty && TERM != NULL && strcmp(TERM, "dumb") != 0;
}
/*!
* \brief colorize Colorizes given text using escape sequences.
* \param text Text to colorize.
* \param params String which describes styling in escape sequence.
* \return Colorized text.
*/
static std::string colorize(const std::string &text, const char *params)
{
return std::string("\033[") + params + "m" + text + "\033[0m";
}
namespace gpui
{
namespace logger
{
/*!
* \class ConsoleLogger consolelogger.h
* \brief Implementation of logger which logs messages to console.
* \ingroup logger
*
* Logs messages to std::clog.
*/
/*!
* \brief ConsoleLogger Create new console logger.
*
* Checks if stderr supports color.
*/
ConsoleLogger::ConsoleLogger()
{
this->hasColorSupport = checkColorSupport(STDERR_FILENO);
}
/*!
* \brief ConsoleLogger::log Send message to console.
* \param message Message.
*
* Formats and sends message to std::clog.
*/
void ConsoleLogger::log(const LoggerMessage &message)
{
std::string prefix = this->logLevelMap.at(message.msgType);
if (this->hasColorSupport)
{
switch (message.msgType)
{
case QtDebugMsg:
prefix = this->hasColorSupport ? colorize(prefix, "1;96") : prefix;
break;
case QtInfoMsg:
prefix = this->hasColorSupport ? colorize(prefix, "1;34") : prefix;
break;
case QtWarningMsg:
prefix = this->hasColorSupport ? colorize(prefix, "1;33") : prefix;
break;
case QtCriticalMsg:
prefix = this->hasColorSupport ? colorize(prefix, "1;31") : prefix;
break;
case QtFatalMsg:
prefix = this->hasColorSupport ? colorize(prefix, "1;91") : prefix;
break;
}
}
std::clog << message.getTimeFormatted("%H:%M:%S") << " | " << prefix << ": " << message.message << " ("
<< message.filePath << ":" << message.line << ")" << std::endl;
}
} // namespace logger
} // namespace gpui

View File

@ -0,0 +1,45 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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_CONSOLE_LOGGER_H
#define GPUI_CONSOLE_LOGGER_H
#include "logger.h"
#include "loggermessage.h"
#include "../core.h"
namespace gpui
{
namespace logger
{
class GPUI_CORE_EXPORT ConsoleLogger : public Logger
{
public:
ConsoleLogger();
private:
void log(const LoggerMessage &message) override;
bool hasColorSupport = false;
};
} // namespace logger
} // namespace gpui
#endif // GPUI_CONSOLE_LOGGER_H

View File

@ -0,0 +1,140 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "filelogger.h"
#include <iostream>
#include <pwd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
namespace gpui
{
namespace logger
{
/*!
* \class FileLogger filelogger.h
* \brief Implementation of logger which logs messages to a file.
* \ingroup logger
*
* Writes logs to ~/.local/share/gpui/<filename>.
*/
/*!
* \brief FileLogger::FileLogger Creates FileLogger
* \param filename Name of a file for logs. By default "gpui.log".
*
* File logger writes to a file in ~/.local/share/gpui/<filename>.
* If given path does not exist, it will create needed directories.
*
* Opens a file stream to log file.
*/
FileLogger::FileLogger(const char *filename)
{
// TODO(mchernigin): timestamp on creation/editing log file is UTC and not local timezone
std::string homeDir = getHomeDir();
std::string logDir = homeDir + "/.local/share/gpui/";
ensureDir(logDir.c_str());
std::string logFile = logDir + filename;
this->logFileStream.open(logFile, std::fstream::out | std::fstream::app);
}
/*!
* \brief FileLogger::~FileLogger Destroys a file logger.
*
* Closes file stream to log file.
*/
FileLogger::~FileLogger()
{
this->logFileStream.close();
}
/*!
* \brief FileLogger::log Format and log given message to log file.
* \param message Message.
*/
void FileLogger::log(const LoggerMessage &message)
{
const char *prefix = this->logLevelMap.at(message.msgType);
this->logFileStream << message.getTimeFormatted("%H:%M:%S") << " | " << prefix << ": " << message.message << " ("
<< message.filePath << ":" << message.line << ")" << std::endl;
}
/*!
* \brief FileLogger::getHomeDir Gets current user home directory.
* \return Absolute path to home directory.
*
* Gets home directory from $HOME. If $HOME is not set, uses `getpwuid`.
*/
std::string FileLogger::getHomeDir()
{
const char *HOME = getenv("HOME");
if (HOME != NULL)
{
return HOME;
}
long bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
if (bufsize == -1)
{
bufsize = 1 << 14;
}
char *resultBuf = new char[bufsize];
passwd pwd;
passwd *result;
getpwuid_r(getuid(), &pwd, resultBuf, bufsize, &result);
std::string homeDir;
if (result != NULL)
{
homeDir = result->pw_dir;
}
else
{
homeDir = "/root";
std::cerr << "FileLogger Error: cannot determine home directory, defaulting to " << homeDir << std::endl;
}
delete[] resultBuf;
return homeDir;
}
/*!
* \brief FileLogger::ensureDir Ensure if given path exists.
* \param path Path
* \return True, if dir already exists or was created successfully.
*/
bool FileLogger::ensureDir(const char *path)
{
struct stat sb;
if (stat(path, &sb) != 0 && mkdir(path, 0750) != 0)
{
std::cerr << "FileLogger Error: Cannot create log directory (" << path << ")" << std::endl;
return false;
}
return true;
}
} // namespace logger
} // namespace gpui

View File

@ -0,0 +1,51 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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_FILE_LOGGER_H
#define GPUI_FILE_LOGGER_H
#include "logger.h"
#include "loggermessage.h"
#include "../core.h"
#include <fstream>
namespace gpui
{
namespace logger
{
class GPUI_CORE_EXPORT FileLogger : public Logger
{
public:
explicit FileLogger(const char *filename = "gpui.log");
~FileLogger();
private:
void log(const LoggerMessage &message) override;
static std::string getHomeDir();
static bool ensureDir(const char *path);
std::fstream logFileStream = {};
};
} // namespace logger
} // namespace gpui
#endif // GPUI_FILE_LOGGER_H

View File

@ -0,0 +1,66 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "logger.h"
namespace gpui
{
namespace logger
{
/*!
* \class Logger logger.h
* \brief Abstract logger.
* \ingroup logger
*/
/*!
* \brief Logger::setLogLevel Set minimum logging level.
* \param level Minimum logging level.
*/
void Logger::setLogLevel(QtMsgType level)
{
this->minLogLevel = level;
}
/*!
* \brief Logger::isLogLevel Check if log level will be logged.
* \param level Logging level.
* \return Returns true if givven logging level will be logged.
*/
bool Logger::isLogLevel(QtMsgType level)
{
return level >= this->minLogLevel;
}
/*!
* \brief Logger::logMessage Log message.
* \param message Message.
*
* Logs only message logging level equals or above minimum logging level.
*/
void Logger::logMessage(const LoggerMessage &message)
{
if (isLogLevel(message.msgType))
{
log(message);
}
}
} // namespace logger
} // namespace gpui

71
src/core/logger/logger.h Normal file
View File

@ -0,0 +1,71 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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_ABSTRACT_LOGGER_H
#define GPUI_ABSTRACT_LOGGER_H
#include "../core.h"
#include "loggermessage.h"
#include <fstream>
#include <unordered_map>
#include <QtMsgHandler>
#define LOG_LEVEL_DISABLED static_cast<QtMsgType>(-1)
namespace gpui
{
namespace logger
{
class GPUI_CORE_EXPORT Logger
{
public:
Logger() = default;
virtual ~Logger() = default;
void setLogLevel(QtMsgType level);
bool isLogLevel(QtMsgType level);
void logMessage(const LoggerMessage &message);
private:
Logger(const Logger &) = delete; // copy ctor
Logger(Logger &&) = delete; // move ctor
Logger &operator=(const Logger &) = delete; // copy assignment
Logger &operator=(Logger &&) = delete; // move assignment
private:
virtual void log(const LoggerMessage &message) = 0;
QtMsgType minLogLevel = QtDebugMsg;
protected:
const std::unordered_map<QtMsgType, const char *> logLevelMap = {
{QtDebugMsg, "DEBUG"},
{QtInfoMsg, "INFO"},
{QtWarningMsg, "WARNING"},
{QtCriticalMsg, "CRITICAL"},
{QtFatalMsg, "FATAL"},
};
};
} // namespace logger
} // namespace gpui
#endif // GPUI_ABSTRACT_LOGGER_H

View File

@ -0,0 +1,184 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "loggermanager.h"
#include <algorithm>
#include <iostream>
/*!
* \brief getCurrentTime Returns current system time.
* \return Time struct.
*/
static std::tm getCurrentTime()
{
time_t time;
std::time(&time);
// NOTE: localtime returns a pointer to a statically allocated object
return *std::localtime(&time);
}
namespace gpui
{
namespace logger
{
class LoggerManagerPrivate
{
public:
std::vector<std::shared_ptr<Logger>> loggers = {};
mutable std::mutex loggerMutex = {};
};
/*!
* \class LoggerManager loggermanager.h
* \brief Class for managing loggers.
* \ingroup logger
*
* Provides ability to enable new loggers.
*/
std::shared_ptr<LoggerManager> LoggerManager::instance{nullptr};
/*!
* \brief LoggerManager::LoggerManager Create new LoggerManager.
*
* Installs qt message handler to its own static function.
*/
LoggerManager::LoggerManager()
: d(new LoggerManagerPrivate)
{
qInstallMessageHandler(LoggerManager::messageHandler);
}
/*!
* \brief LoggerManager::~LoggerManager Destroy logger manager.
*/
LoggerManager::~LoggerManager()
{
delete d;
}
/*!
* \brief LoggerManager::destroyInstance Destroy global logger manager instance.
*/
void LoggerManager::destroyInstance()
{
instance.reset();
}
/*!
* \brief LoggerManager::addLogger Add new logger.
* \param logger New logger.
*
* Enables given logger.
*/
void LoggerManager::addLogger(std::shared_ptr<Logger> logger)
{
std::lock_guard<std::mutex> lockGuardLogger(d->loggerMutex);
d->loggers.push_back(logger);
}
/*!
* \brief LoggerManager::removeLogger Remove logger.
* \param logger Logger.
*
* Disables given logger.
*/
void LoggerManager::removeLogger(std::shared_ptr<Logger> logger)
{
std::lock_guard<std::mutex> lockGuardLogger(d->loggerMutex);
const auto search = std::find(d->loggers.begin(), d->loggers.end(), logger);
if (search != d->loggers.end())
{
d->loggers.erase(search);
}
}
/*!
* \brief LoggerManager::clearLoggers Remove all logger.
*
* Disables all loggers.
*/
void LoggerManager::clearLoggers()
{
d->loggers.clear();
}
/*!
* \brief LoggerManager::log Log message to all loggers.
* \param msgType Log level.
* \param message Message text.
* \param file File where logger was invoked.
* \param function Function where logger was invoked.
* \param line Line where logger was invoked.
*/
void LoggerManager::log(const QtMsgType &msgType,
const std::string &message,
const std::string &file,
const std::string &function,
const uint32_t line)
{
std::lock_guard<std::mutex> lockGuardLogger(d->loggerMutex);
for (const auto &logger : d->loggers)
{
logger->logMessage(
LoggerMessage(msgType, message, file, function, line, getCurrentTime(), std::this_thread::get_id()));
}
}
/*!
* \brief LoggerManager::getLoggerCount Get number of enabled loggers.
* \return Number of loggers.
*/
size_t LoggerManager::getLoggerCount() const
{
std::lock_guard<std::mutex> lockGuardLogger(d->loggerMutex);
return d->loggers.size();
}
/*!
* \brief LoggerManager::messageHandler Handler of all log messages.
* \param msgType Log level.
* \param context Qt context.
* \param msg Message text.
*/
void LoggerManager::messageHandler(QtMsgType msgType, const QMessageLogContext &context, const QString &msg)
{
auto logger = globalInstance();
std::string file = context.file ? context.file : "";
std::string function = context.function ? context.function : "";
int line = context.line;
logger->log(msgType, msg.toStdString(), file, function, line);
}
Q_GLOBAL_STATIC(LoggerManager, loggerInstance)
/*!
* \brief LoggerManager::globalInstance Get global instance of logger manager.
* \return Pointer to logger manager.
*/
LoggerManager *LoggerManager::globalInstance()
{
return loggerInstance();
}
} // namespace logger
} // namespace gpui

View File

@ -0,0 +1,82 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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_LOGGER_MANAGER_H
#define GPUI_LOGGER_MANAGER_H
#include "../core.h"
#include "logger.h"
#include <memory>
#include <mutex>
#include <vector>
#include <QString>
namespace gpui
{
namespace logger
{
class LoggerManagerPrivate;
class GPUI_CORE_EXPORT LoggerManager
{
public:
static LoggerManager *globalInstance();
static void destroyInstance();
LoggerManager();
~LoggerManager();
void addLogger(std::shared_ptr<Logger> logger);
void removeLogger(std::shared_ptr<Logger> logger);
void clearLoggers();
size_t getLoggerCount() const;
void log(const QtMsgType &msgType,
const std::string &message,
const std::string &file,
const std::string &function,
const uint32_t line);
template<typename T>
void addLogger(const QtMsgType &level)
{
auto logger = std::make_shared<T>();
logger->setLogLevel(level);
this->addLogger(logger);
}
private:
LoggerManager(const LoggerManager &) = delete; // copy ctor
LoggerManager(LoggerManager &&) = delete; // move ctor
LoggerManager &operator=(const LoggerManager &) = delete; // copy assignment
LoggerManager &operator=(LoggerManager &&) = delete; // move assignment
private:
static void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
static std::shared_ptr<LoggerManager> instance;
LoggerManagerPrivate *d;
};
} // namespace logger
} // namespace gpui
#endif // GPUI_LOGGER_MANAGER_H

View File

@ -0,0 +1,75 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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_LOGGER_MESSAGE_H
#define GPUI_LOGGER_MESSAGE_H
#include <ctime>
#include <string>
#include <thread>
#include <QtMsgHandler>
namespace gpui
{
namespace logger
{
class LoggerMessage
{
public:
LoggerMessage(const QtMsgType &msgType_,
const std::string &message_,
const std::string &filePath_,
const std::string &functionName_,
const uint32_t line_,
const std::tm &time_,
const std::thread::id &threadId_)
: msgType(msgType_)
, message(message_)
, filePath(filePath_)
, functionName(functionName_)
, line(line_)
, time(time_)
, threadId(threadId_)
{}
std::string getTimeFormatted(const char *format) const
{
char timeString[50];
// NOTE(mchernigin): do all compilers actually support this?
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
strftime(timeString, 50, format, &time);
#pragma GCC diagnostic pop
return std::string(timeString);
}
const QtMsgType &msgType;
const std::string message;
const std::string filePath;
const std::string functionName;
const uint32_t line;
const std::tm time;
const std::thread::id threadId;
};
} // namespace logger
} // namespace gpui
#endif // GPUI_LOGGER_MESSAGE_H

30
src/core/logger/prelude.h Normal file
View File

@ -0,0 +1,30 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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_LOGGERS_H
#define GPUI_LOGGERS_H
#include "loggermanager.h"
#include "consolelogger.h"
#include "filelogger.h"
#include "sysloglogger.h"
#endif // GPUI_LOGGERS_H

View File

@ -0,0 +1,86 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "sysloglogger.h"
#include <sstream>
#include <syslog.h>
namespace gpui
{
namespace logger
{
/*!
* \class SyslogLogger syslogger.h
* \brief Implementation of logger which logs messages to syslog.
* \ingroup logger
*/
/*!
* \brief SyslogLogger::SyslogLogger Create new syslog logger.
*
* Opens syslog connection.
*/
SyslogLogger::SyslogLogger()
{
openlog("gpui", (LOG_CONS | LOG_PID), LOG_USER);
}
/*!
* \brief SyslogLogger::~SyslogLogger Destroy syslog logger.
*
* Closes syslog connection.
*/
SyslogLogger::~SyslogLogger()
{
closelog();
}
/*!
* \brief SyslogLogger::log Send message to syslog.
* \param message Message.
*/
void SyslogLogger::log(const LoggerMessage &message)
{
const char *prefix = this->logLevelMap.at(message.msgType);
int logFlag = LOG_DEBUG;
switch (message.msgType)
{
case QtInfoMsg:
logFlag = LOG_INFO;
break;
case QtWarningMsg:
logFlag = LOG_WARNING;
break;
case QtCriticalMsg:
logFlag = LOG_ERR;
break;
case QtFatalMsg:
logFlag = LOG_CRIT;
break;
default:
break;
}
syslog(logFlag, "%s: %s (%s:%u)", prefix, message.message.c_str(), message.filePath.c_str(), message.line);
}
} // namespace logger
} // namespace gpui

View File

@ -0,0 +1,46 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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_SYSLOG_LOGGER_H
#define GPUI_SYSLOG_LOGGER_H
#include "logger.h"
#include "loggermessage.h"
#include "../core.h"
#include <fstream>
namespace gpui
{
namespace logger
{
class GPUI_CORE_EXPORT SyslogLogger : public Logger
{
public:
SyslogLogger();
~SyslogLogger();
private:
void log(const LoggerMessage &message) override;
};
} // namespace logger
} // namespace gpui
#endif // GPUI_SYSLOG_LOGGER_H

75
src/core/plugin.cpp Normal file
View File

@ -0,0 +1,75 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "plugin.h"
#include "pluginstorage.h"
#include <QLibrary>
namespace gpui
{
class PluginPrivate
{
public:
QString name = {};
std::unique_ptr<QLibrary> library = nullptr;
std::map<QString, std::function<void *()>> pluginClasses = {};
};
Plugin::~Plugin()
{
delete d;
}
const QString &Plugin::getName() const
{
return d->name;
}
void Plugin::setLibrary(std::unique_ptr<QLibrary> library)
{
d->library = std::move(library);
}
QLibrary *Plugin::getLibrary() const
{
return d->library.get();
}
const std::map<QString, std::function<void *()>> &Plugin::getPluginClasses() const
{
return d->pluginClasses;
}
Plugin::Plugin(const QString &name)
: d(new PluginPrivate())
{
d->name = name;
}
Plugin::Plugin(const char *name)
: Plugin(QString(name))
{}
void Plugin::registerPluginClass(const QString &name, std::function<void *()> constructor)
{
d->pluginClasses[name] = constructor;
}
} // namespace gpui

View File

@ -1,6 +1,6 @@
/***********************************************************************************************************************
**
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
@ -21,7 +21,7 @@
#ifndef GPUI_PLUGIN_H
#define GPUI_PLUGIN_H
#include "model.h"
#include "core.h"
#include "common.h"
@ -32,40 +32,43 @@
class QLibrary;
class QString;
namespace gpui {
class PluginPrivate;
class PluginStorage;
namespace gpui
{
class PluginPrivate;
class PluginStorage;
class GPUI_MODEL_EXPORT Plugin
{
public:
virtual ~Plugin();
class GPUI_CORE_EXPORT Plugin
{
public:
virtual ~Plugin();
const QString& getName() const;
const QString &getName() const;
void setLibrary(std::unique_ptr<QLibrary> library);
QLibrary* getLibrary() const;
void setLibrary(std::unique_ptr<QLibrary> library);
QLibrary *getLibrary() const;
const std::map<QString, std::function<void *()> > &getPluginClasses() const;
const std::map<QString, std::function<void *()>> &getPluginClasses() const;
protected:
explicit Plugin(const QString& name);
explicit Plugin(const char* name);
protected:
explicit Plugin(const QString &name);
explicit Plugin(const char *name);
void registerPluginClass(const QString& name, std::function<void*()> constructor);
void registerPluginClass(const QString &name, std::function<void *()> constructor);
private:
PluginPrivate* d;
};
}
private:
Plugin(const Plugin &) = delete; // copy ctor
Plugin(Plugin &&) = delete; // move ctor
Plugin &operator=(const Plugin &) = delete; // copy assignment
Plugin &operator=(Plugin &&) = delete; // move assignment
private:
PluginPrivate *d;
};
} // namespace gpui
#define GPUI_EXPORT_PLUGIN(name, className) \
extern "C" GPUI_SYMBOL_EXPORT gpui::Plugin* gpui_plugin_init() \
{ \
return new className; \
}
extern "C" GPUI_SYMBOL_EXPORT ::gpui::Plugin *gpui_plugin_init() { return new className; }
#define GPUI_REGISTER_PLUGIN_CLASS(name, pluginClass) \
registerPluginClass(name, [](){ return new pluginClass(); })
#define GPUI_REGISTER_PLUGIN_CLASS(name, pluginClass) registerPluginClass(name, []() { return new pluginClass(); })
#endif // GPUI_PLUGIN_H

View File

@ -1,6 +1,6 @@
/***********************************************************************************************************************
**
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
@ -27,23 +27,22 @@
#include <map>
#include <memory>
namespace gpui {
namespace gpui
{
class PluginStoragePrivate
{
public:
std::map<QString, std::unique_ptr<Plugin> > pluginMap;
std::map<QString, std::map<QString, std::function<void*()> > > classMap;
public:
std::map<QString, std::unique_ptr<Plugin>> pluginMap = {};
std::map<QString, std::map<QString, std::function<void *()>>> classMap = {};
};
PluginStorage::PluginStorage()
: d(new PluginStoragePrivate())
{
}
{}
PluginStorage::~PluginStorage()
{
for (auto& plugin : d->pluginMap)
for (auto &plugin : d->pluginMap)
{
unloadPlugin(plugin.first);
}
@ -51,24 +50,25 @@ PluginStorage::~PluginStorage()
delete d;
}
Plugin* PluginStorage::getPlugin(const QString& pluginName)
Plugin *PluginStorage::getPlugin(const QString &pluginName)
{
auto search = d->pluginMap.find(pluginName);
if (search != d->pluginMap.end()) {
if (search != d->pluginMap.end())
{
return search->second.get();
}
return nullptr;
}
PluginStorage* PluginStorage::instance()
{
PluginStorage *PluginStorage::instance()
{
static PluginStorage instance;
return &instance;
}
bool PluginStorage::loadPlugin(const QFileInfo& fileName)
bool PluginStorage::loadPlugin(const QFileInfo &fileName, QString &pluginName)
{
std::unique_ptr<QLibrary> pluginLibrary = std::make_unique<QLibrary>(fileName.absoluteFilePath());
if (!pluginLibrary->load())
@ -78,8 +78,8 @@ bool PluginStorage::loadPlugin(const QFileInfo& fileName)
return false;
}
typedef gpui::Plugin* (*gpui_plugin_init)();
gpui_plugin_init initFunction = (gpui_plugin_init)pluginLibrary->resolve("gpui_plugin_init");
typedef ::gpui::Plugin *(*gpui_plugin_init)();
gpui_plugin_init initFunction = reinterpret_cast<gpui_plugin_init>(pluginLibrary->resolve("gpui_plugin_init"));
if (!initFunction)
{
@ -88,17 +88,20 @@ bool PluginStorage::loadPlugin(const QFileInfo& fileName)
return false;
}
Plugin* plugin = initFunction();
Plugin *plugin = initFunction();
if (!plugin) {
if (!plugin)
{
// TODO: Log results.
return false;
}
pluginName = plugin->getName();
plugin->setLibrary(std::move(pluginLibrary));
for (const auto& entry : plugin->getPluginClasses())
for (const auto &entry : plugin->getPluginClasses())
{
registerPluginClass(plugin->getName(), entry.first, entry.second);
}
@ -108,22 +111,24 @@ bool PluginStorage::loadPlugin(const QFileInfo& fileName)
return true;
}
void PluginStorage::loadPluginDirectory(const QString& directoryName)
void PluginStorage::loadPluginDirectory(const QString &directoryName)
{
QDir directory(directoryName);
const QFileInfoList files = directory.entryInfoList();
QString pluginName;
for (const QFileInfo& file : files) {
loadPlugin(file);
for (const QFileInfo &file : files)
{
loadPlugin(file, pluginName);
}
}
bool PluginStorage::unloadPlugin(const QString& pluginName)
bool PluginStorage::unloadPlugin(const QString &pluginName)
{
auto search = d->pluginMap.find(pluginName);
if (search != d->pluginMap.end())
{
for (const auto& entry : search->second->getPluginClasses())
for (const auto &entry : search->second->getPluginClasses())
{
unregisterPluginClass(search->second->getName(), entry.first);
}
@ -136,7 +141,7 @@ bool PluginStorage::unloadPlugin(const QString& pluginName)
return false;
}
bool PluginStorage::unloadPlugin(Plugin* plugin)
bool PluginStorage::unloadPlugin(Plugin *plugin)
{
if (plugin)
{
@ -147,29 +152,38 @@ bool PluginStorage::unloadPlugin(Plugin* plugin)
}
void PluginStorage::loadDefaultPlugins()
{
{
loadPluginDirectory("/usr/lib/gpui/plugins/");
loadPluginDirectory("/usr/lib64/gpui/plugins/");
QString customPluginDir = qgetenv("GPUI_PLUGIN_DIRECTORY");
if (!customPluginDir.isEmpty())
{
loadPluginDirectory(customPluginDir);
}
}
void PluginStorage::registerPluginClass(const QString& pluginName, const QString& className, std::function<void*()> constructor)
void PluginStorage::registerPluginClass(const QString &pluginName,
const QString &className,
std::function<void *()> constructor)
{
auto search = d->classMap.find(pluginName);
if (search == d->classMap.end())
{
d->classMap[pluginName] = std::map<QString, std::function<void*()> >();
d->classMap[pluginName] = std::map<QString, std::function<void *()>>();
}
std::map<QString, std::function<void*()> >& pluginConstructors = d->classMap[pluginName];
pluginConstructors[className] = constructor;
std::map<QString, std::function<void *()>> &pluginConstructors = d->classMap[pluginName];
pluginConstructors[className] = constructor;
}
bool PluginStorage::unregisterPluginClass(const QString& pluginName, const QString& className)
bool PluginStorage::unregisterPluginClass(const QString &pluginName, const QString &className)
{
auto plugin = d->classMap.find(pluginName);
if (plugin != d->classMap.end())
{
auto search = plugin->second.find(className);
if (search != plugin->second.end()) {
if (search != plugin->second.end())
{
d->classMap[pluginName].erase(search);
return true;
}
@ -178,15 +192,19 @@ bool PluginStorage::unregisterPluginClass(const QString& pluginName, const QStri
return false;
}
void* PluginStorage::createPluginClass(const QString &className, const QString &pluginName)
void *PluginStorage::createPluginClass(const QString &className, const QString &pluginName)
{
auto search = d->classMap.find(pluginName);
if (search != d->classMap.end())
{
return search->second[className]();
auto classType = search->second.find(className);
if (classType != search->second.end())
{
return search->second[className]();
}
}
return nullptr;
}
}
} // namespace gpui

View File

@ -1,6 +1,6 @@
/***********************************************************************************************************************
**
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
@ -21,7 +21,7 @@
#ifndef GPUI_PLUGINSTORAGE_H
#define GPUI_PLUGINSTORAGE_H
#include "model.h"
#include "core.h"
#include <QString>
@ -30,8 +30,8 @@
class QFileInfo;
namespace gpui {
namespace gpui
{
class Plugin;
class PluginStoragePrivate;
@ -41,7 +41,7 @@ class PluginStoragePrivate;
*
* \ingroup gpui
*/
class GPUI_MODEL_EXPORT PluginStorage
class GPUI_CORE_EXPORT PluginStorage
{
public:
/*!
@ -49,34 +49,35 @@ public:
* \param pluginName
* \return
*/
Plugin *getPlugin(const QString& pluginName);
Plugin *getPlugin(const QString &pluginName);
/*!
* \brief loadPlugin
* \param fileName
* \param pluginName - If load operation was successfull contains name of a plugin.
* \return
*/
bool loadPlugin(const QFileInfo &fileName);
bool loadPlugin(const QFileInfo &fileName, QString &pluginName);
/*!
* \brief loadPluginDirectory
* \param directoryName
*/
void loadPluginDirectory(const QString& directoryName);
void loadPluginDirectory(const QString &directoryName);
/*!
* \brief unloadPlugin
* \param pluginName
* \return
*/
bool unloadPlugin(const QString& pluginName);
bool unloadPlugin(const QString &pluginName);
/*!
* \brief unloadPlugin
* \param plugin
* \return
*/
bool unloadPlugin(Plugin* plugin);
bool unloadPlugin(Plugin *plugin);
/**
* @brief loadDefaultPlugins
@ -87,26 +88,32 @@ public:
* \brief createPluginClass
*/
template<typename T>
T* createPluginClass(const QString& pluginName)
T *createPluginClass(const QString &pluginName)
{
return reinterpret_cast<T*>(createPluginClass(typeid(T).name(), pluginName));
return reinterpret_cast<T *>(createPluginClass(typeid(T).name(), pluginName));
}
static PluginStorage* instance();
static PluginStorage *instance();
private:
void registerPluginClass(const QString& pluginName, const QString& className, std::function<void*()> constructor);
bool unregisterPluginClass(const QString& pluginName, const QString& className);
void registerPluginClass(const QString &pluginName, const QString &className, std::function<void *()> constructor);
bool unregisterPluginClass(const QString &pluginName, const QString &className);
void *createPluginClass(const QString& className, const QString& pluginName);
void *createPluginClass(const QString &className, const QString &pluginName);
PluginStorage();
~PluginStorage();
private:
PluginStoragePrivate* d;
PluginStorage(const PluginStorage &) = delete; // copy ctor
PluginStorage(PluginStorage &&) = delete; // move ctor
PluginStorage &operator=(const PluginStorage &) = delete; // copy assignment
PluginStorage &operator=(PluginStorage &&) = delete; // move assignment
private:
PluginStoragePrivate *d;
};
}
} // namespace gpui
#endif // GPUI_PLUGINSTORAGE_H

View File

@ -0,0 +1,50 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "snapindetailsdialog.h"
#include "ui_snapindetailsdialog.h"
#include <QDialog>
namespace gpui
{
SnapInDetailsDialog::SnapInDetailsDialog(QWidget *parent, ::gpui::ISnapIn *snapIn)
: SnapInDetailsDialog(parent)
{
setSnapIn(snapIn);
}
SnapInDetailsDialog::SnapInDetailsDialog(QWidget *parent)
: ISnapInDetailsDialog(parent)
, ui(new Ui::SnapInDetailsDialog())
{
ui->setupUi(this);
}
SnapInDetailsDialog::~SnapInDetailsDialog()
{
delete ui;
}
void SnapInDetailsDialog::setSnapIn(ISnapIn *snapIn)
{
ui->snapInWidget->setSnapIn(snapIn);
}
} // namespace gpui

View File

@ -0,0 +1,64 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 _SNAPINDETAILSDIALOG_H
#define _SNAPINDETAILSDIALOG_H
#include "core.h"
#include "isnapin.h"
#include "isnapindetailsdialog.h"
namespace Ui
{
class SnapInDetailsDialog;
}
namespace gpui
{
/**
* @brief class SnapInDetailsDialog Shows properties of a snap-in.
* Provides information on snap-in name, description, version, copyright, lisense.
*/
class GPUI_CORE_EXPORT SnapInDetailsDialog : public ISnapInDetailsDialog
{
private:
Q_OBJECT
public:
SnapInDetailsDialog(QWidget *parent, ISnapIn *snapIn);
SnapInDetailsDialog(QWidget *parent = nullptr);
~SnapInDetailsDialog();
void setSnapIn(ISnapIn *snapIn) override;
private:
SnapInDetailsDialog(const SnapInDetailsDialog &) = delete; // copy ctor
SnapInDetailsDialog(SnapInDetailsDialog &&) = delete; // move ctor
SnapInDetailsDialog &operator=(const SnapInDetailsDialog &) = delete; // copy assignment
SnapInDetailsDialog &operator=(SnapInDetailsDialog &&) = delete; // move assignment
private:
Ui::SnapInDetailsDialog *ui;
};
} // namespace gpui
#endif //_SNAPINDETAILSDIALOG_H

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SnapInDetailsDialog</class>
<widget class="QDialog" name="SnapInDetailsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="::gpui::SnapInDetailsWidget" name="snapInWidget" native="true">
<property name="minimumSize">
<size>
<width>400</width>
<height>300</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>::gpui::SnapInDetailsWidget</class>
<extends>QWidget</extends>
<header>snapindetailswidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>clicked(QAbstractButton*)</signal>
<receiver>SnapInDetailsDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>241</x>
<y>281</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>150</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,27 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "snapindetailsfactory.h"
namespace gpui
{
::gpui::Factory<ISnapInDetailsDialog, QString> SnapInDetailsFactory::factory
= ::gpui::Factory<ISnapInDetailsDialog, QString>();
}

View File

@ -0,0 +1,60 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 _SNAPINDETAILSFACTORYBASE_H
#define _SNAPINDETAILSFACTORYBASE_H
#include "core.h"
#include "factory.h"
#include "isnapindetailsdialog.h"
namespace gpui
{
/**
* @brief Base for all for snap-in dialog factories.
*/
class GPUI_CORE_EXPORT SnapInDetailsFactory
{
public:
typedef ::gpui::Factory<ISnapInDetailsDialog, QString> Factory;
virtual ~SnapInDetailsFactory() = default;
static Factory::Type create(Factory::Key const &name) { return factory.create(name); }
template<class Derived>
static void define(Factory::Key const &name)
{
bool new_key = factory.define(name, &Factory::template create_func<ISnapInDetailsDialog, Derived>);
if (!new_key)
{
throw std::logic_error(std::string(__PRETTY_FUNCTION__) + ": name is already registered!");
}
}
private:
static Factory factory;
};
} // namespace gpui
#define REGISTER_DETAILS_DIALOG_CLASS(cls) static SnapInDetailsFactory myfactory::define<#cls>(new #cls().getType());
#endif //_SNAPINDETAILSFACTORYBASE_H

View File

@ -0,0 +1,56 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "snapindetailswidget.h"
#include "ui_snapindetailswidget.h"
#include <QWidget>
namespace gpui
{
SnapInDetailsWidget::SnapInDetailsWidget(QWidget *parent, ::gpui::ISnapIn *snapIn)
: SnapInDetailsWidget(parent)
{
setSnapIn(snapIn);
}
SnapInDetailsWidget::SnapInDetailsWidget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::SnapInDetailsWidget())
{
ui->setupUi(this);
}
SnapInDetailsWidget::~SnapInDetailsWidget()
{
delete ui;
}
void SnapInDetailsWidget::setSnapIn(const ISnapIn *snapIn)
{
ui->categoryLineEdit->setText(snapIn->getId().toString());
ui->copyrightLineEdit->setText(snapIn->getCopyright());
ui->descriptionPlainTextEdit->setPlainText(snapIn->getHelpText());
ui->licensePlainTextEdit->setPlainText(snapIn->getLicense());
ui->nameLineEdit->setText(snapIn->getDisplayName());
ui->versionLineEdit->setText(snapIn->getVersion().toString());
}
} // namespace gpui

View File

@ -0,0 +1,65 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 _SNAPINDETAILSWIDGET_H
#define _SNAPINDETAILSWIDGET_H
#include "core.h"
#include <QWidget>
#include "isnapin.h"
namespace Ui
{
class SnapInDetailsWidget;
}
namespace gpui
{
/**
* @brief class SnapInDetailsWidget Shows properties of a snap-in.
* Provides information on snap-in name, description, version, copyright, lisense.
*/
class GPUI_CORE_EXPORT SnapInDetailsWidget : public QWidget
{
private:
Q_OBJECT
public:
SnapInDetailsWidget(QWidget *parent, ISnapIn *snapIn);
SnapInDetailsWidget(QWidget *parent);
~SnapInDetailsWidget();
void setSnapIn(const ISnapIn *snapIn);
private:
SnapInDetailsWidget(const SnapInDetailsWidget &) = delete; // copy ctor
SnapInDetailsWidget(SnapInDetailsWidget &&) = delete; // move ctor
SnapInDetailsWidget &operator=(const SnapInDetailsWidget &) = delete; // copy assignment
SnapInDetailsWidget &operator=(SnapInDetailsWidget &&) = delete; // move assignment
private:
Ui::SnapInDetailsWidget *ui;
};
} // namespace gpui
#endif //_SNAPINDETAILSWIDGET_H

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SnapInDetailsWidget</class>
<widget class="QWidget" name="SnapInDetailsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<widget class="QLabel" name="descriptionLabel">
<property name="text">
<string>Description:</string>
</property>
<property name="buddy">
<cstring>descriptionPlainTextEdit</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPlainTextEdit" name="licensePlainTextEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPlainTextEdit" name="descriptionPlainTextEdit">
<property name="undoRedoEnabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="versionLabel">
<property name="text">
<string>Version:</string>
</property>
<property name="buddy">
<cstring>versionLineEdit</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="categoryLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="versionLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="copyrightLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="categoryLabel">
<property name="text">
<string>Category:</string>
</property>
<property name="buddy">
<cstring>categoryLineEdit</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="copyrightLabel">
<property name="text">
<string>Copyright:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="licenseLabel">
<property name="text">
<string>License:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>Name:</string>
</property>
<property name="buddy">
<cstring>nameLineEdit</cstring>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

83
src/core/snapinloader.cpp Normal file
View File

@ -0,0 +1,83 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "snapinloader.h"
#include "plugin.h"
#include "pluginstorage.h"
#include "isnapin.h"
#include "isnapinmanager.h"
namespace gpui
{
class SnapInLoaderPrivate
{
public:
ISnapInManager *manager{nullptr};
SnapInLoaderPrivate(ISnapInManager *existingManager)
: manager(existingManager)
{}
};
SnapInLoader::SnapInLoader(ISnapInManager *manager)
: d(new SnapInLoaderPrivate(manager))
{}
SnapInLoader::~SnapInLoader()
{
delete d;
}
void SnapInLoader::loadSnapIns(const QDir &snapInDirectory)
{
const QFileInfoList files = snapInDirectory.entryInfoList();
QString pluginName;
for (const QFileInfo &file : files)
{
if (PluginStorage::instance()->loadPlugin(file, pluginName))
{
auto snapIn = PluginStorage::instance()->createPluginClass<ISnapIn>(pluginName);
if (snapIn)
{
d->manager->addSnapIn(snapIn);
}
}
}
}
void SnapInLoader::loadDefaultSnapIns()
{
QString customPluginDir = qgetenv("GPUI_PLUGIN_DIRECTORY");
if (!customPluginDir.isEmpty())
{
loadSnapIns(QDir(customPluginDir));
}
else
{
loadSnapIns(QDir("/usr/lib/gpui/plugins/"));
loadSnapIns(QDir("/usr/lib64/gpui/plugins/"));
}
}
} // namespace gpui

56
src/core/snapinloader.h Normal file
View File

@ -0,0 +1,56 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 SNAP_IN_LOADER_H
#define SNAP_IN_LOADER_H
#include "core.h"
#include <QDir>
namespace gpui
{
class ISnapInManager;
class SnapInLoaderPrivate;
class GPUI_CORE_EXPORT SnapInLoader
{
public:
SnapInLoader(ISnapInManager *manager);
~SnapInLoader();
void loadSnapIns(const QDir &snapInDirectory);
void loadDefaultSnapIns();
private:
SnapInLoader(const SnapInLoader &) = delete; // copy ctor
SnapInLoader(SnapInLoader &&) = delete; // move ctor
SnapInLoader &operator=(const SnapInLoader &) = delete; // copy assignment
SnapInLoader &operator=(SnapInLoader &&) = delete; // move assignment
private:
SnapInLoaderPrivate *d;
};
} // namespace gpui
#endif //SNAP_IN_LOADER_H

View File

@ -0,0 +1,38 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 _SNAPINMANAGEMENTSETTINGS_H
#define _SNAPINMANAGEMENTSETTINGS_H
#include "core.h"
#include <QSettings>
namespace gpui
{
class GPUI_CORE_EXPORT SnapInManagementSettings
{
private:
QSettings settings;
};
} // namespace gpui
#endif //_SNAPINMANAGEMENTSETTINGS_H

View File

@ -0,0 +1,134 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "snapinmanagementwidget.h"
#include "ui_snapinmanagementwidget.h"
#include "isnapin.h"
#include "snapindetailsfactory.h"
#include <QTableWidget>
#include <QTreeWidgetItem>
#include <QMessageBox>
#include <memory>
Q_DECLARE_METATYPE(::gpui::ISnapIn *)
namespace gpui
{
enum TreeItemColumn
{
FIRST = 0,
ENABLED = 0,
NAME = 1,
VERSION = 2,
};
class SnapInManagementWidgetPrivate
{
public:
Ui::SnapInManagementWidget *ui = nullptr;
ISnapInManager *manager = nullptr;
std::unique_ptr<SnapInDetailsFactory> factory = nullptr;
SnapInManagementWidgetPrivate()
: ui(new Ui::SnapInManagementWidget())
, factory(new SnapInDetailsFactory())
{}
~SnapInManagementWidgetPrivate() { delete ui; }
private:
SnapInManagementWidgetPrivate(const SnapInManagementWidgetPrivate &) = delete; // copy ctor
SnapInManagementWidgetPrivate(SnapInManagementWidgetPrivate &&) = delete; // move ctor
SnapInManagementWidgetPrivate &operator=(const SnapInManagementWidgetPrivate &)
= delete; // copy assignment
SnapInManagementWidgetPrivate &operator=(SnapInManagementWidgetPrivate &&)
= delete; // move assignment
};
SnapInManagementWidget::SnapInManagementWidget(QWidget *parent, ISnapInManager *manager)
: QWidget(parent)
, d(new SnapInManagementWidgetPrivate())
{
d->manager = manager;
d->ui->setupUi(this);
for (ISnapIn *snapIn : manager->getSnapIns())
{
auto snapInItem = new QTreeWidgetItem();
auto enabled = true;
auto version = snapIn->getVersion();
auto displayName = snapIn->getDisplayName();
snapInItem->setText(ENABLED, enabled ? "Yes" : "No");
snapInItem->setText(NAME, displayName);
snapInItem->setText(VERSION, version.toString());
snapInItem->setData(FIRST, Qt::UserRole, QVariant::fromValue(snapIn));
d->ui->treeWidget->addTopLevelItem(snapInItem);
}
d->ui->treeWidget->expandAll();
}
SnapInManagementWidget::~SnapInManagementWidget()
{
delete d;
}
void SnapInManagementWidget::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{
Q_UNUSED(column);
if (!item)
{
return;
}
auto snapIn = item->data(FIRST, Qt::UserRole).value<ISnapIn *>();
if (snapIn)
{
try
{
auto snapInDetailsDialog = d->factory->create(snapIn->getType());
if (snapInDetailsDialog)
{
snapInDetailsDialog->setSnapIn(snapIn);
snapInDetailsDialog->exec();
}
}
catch (const std::exception &error)
{
QMessageBox mb(QMessageBox::Critical,
"Error while creating dialog widget",
error.what(),
QMessageBox::Ok);
mb.exec();
}
}
}
} // namespace gpui

View File

@ -0,0 +1,67 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 _SNAPINMANAGEMENTWIDGET_H
#define _SNAPINMANAGEMENTWIDGET_H
#include "core.h"
#include <QWidget>
#include "isnapinmanager.h"
namespace Ui
{
class SnapInManagementWidget;
}
class QTreeWidgetItem;
namespace gpui
{
class SnapInManagementWidgetPrivate;
/**
* @brief The SnapInManagementWidget class Shows tree of available snap-ins. Enables and disables snap-ins.
*/
class GPUI_CORE_EXPORT SnapInManagementWidget : public QWidget
{
Q_OBJECT
public:
SnapInManagementWidget(QWidget *parent, ISnapInManager *manager);
~SnapInManagementWidget();
private slots:
void on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
private:
SnapInManagementWidget(const SnapInManagementWidget &) = delete; // copy ctor
SnapInManagementWidget(SnapInManagementWidget &&) = delete; // move ctor
SnapInManagementWidget &operator=(const SnapInManagementWidget &) = delete; // copy assignment
SnapInManagementWidget &operator=(SnapInManagementWidget &&) = delete; // move assignment
private:
SnapInManagementWidgetPrivate *d;
};
} // namespace gpui
#endif //_SNAPINMANAGEMENTWIDGET_H

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SnapInManagementWidget</class>
<widget class="QWidget" name="SnapInManagementWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>412</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTreeWidget" name="treeWidget">
<property name="columnCount">
<number>3</number>
</property>
<column>
<property name="text">
<string>Enabled</string>
</property>
</column>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Version</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,78 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 "snapinmanager.h"
#include "isnapin.h"
#include "pluginstorage.h"
#include <algorithm>
namespace gpui
{
class SnapInManagerPrivate
{
public:
std::vector<ISnapIn *> snapIns{};
};
SnapInManager::SnapInManager()
: d(new SnapInManagerPrivate())
{}
SnapInManager::~SnapInManager()
{
for (auto &snapIn : d->snapIns)
{
if (snapIn)
{
delete snapIn;
snapIn = nullptr;
}
}
delete d;
}
void SnapInManager::addSnapIn(ISnapIn *snapIn)
{
d->snapIns.push_back(snapIn);
}
void SnapInManager::removeSnapIn(ISnapIn *snapIn)
{
auto element = std::find(d->snapIns.begin(), d->snapIns.end(), snapIn);
if (element != d->snapIns.end())
{
d->snapIns.erase(element);
}
}
std::vector<ISnapIn *> SnapInManager::getSnapIns() const
{
return d->snapIns;
}
void SnapInManager::clear()
{
d->snapIns.clear();
}
} // namespace gpui

62
src/core/snapinmanager.h Normal file
View File

@ -0,0 +1,62 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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 _SnapInManager_H
#define _SnapInManager_H
#include "core.h"
#include "isnapin.h"
#include "isnapinmanager.h"
namespace gpui
{
class SnapInManagerPrivate;
/**
* @brief The SnapInManager class provides implementation of ISnapInManager interface.
*/
class GPUI_CORE_EXPORT SnapInManager final : public ISnapInManager
{
public:
SnapInManager();
~SnapInManager();
void addSnapIn(ISnapIn *snapIn) override final;
void removeSnapIn(ISnapIn *snapIn) override final;
std::vector<ISnapIn *> getSnapIns() const override final;
void clear() override final;
private:
SnapInManager(const SnapInManager &) = delete; // copy ctor
SnapInManager(SnapInManager &&) = delete; // move ctor
SnapInManager &operator=(const SnapInManager &) = delete; // copy assignment
SnapInManager &operator=(SnapInManager &&) = delete; // move assignment
private:
SnapInManagerPrivate *d;
};
} // namespace gpui
#endif //_SnapInManager_H

View File

@ -0,0 +1,99 @@
/***********************************************************************************************************************
**
** Copyright (C) 2023 BaseALT Ltd. <org@basealt.ru>
**
** 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 "translatorstorage.h"
#include <QCoreApplication>
#include <QDebug>
#include <QDirIterator>
#include <QLibraryInfo>
class TranslatorStoragePrivate
{
public:
std::vector<std::unique_ptr<QTranslator>> translators = {};
QString m_errorString = {};
};
TranslatorStorage::TranslatorStorage()
: d(new TranslatorStoragePrivate())
{}
TranslatorStorage::~TranslatorStorage()
{}
bool TranslatorStorage::loadTranslators(const QString &language)
{
return loadTranslators(language, ":/");
}
bool TranslatorStorage::loadTranslators(const QString &language, const QString &path)
{
QString languageToLoad = language.split("-").at(0);
QDir dir(path);
for (auto &entry : dir.entryList())
{
if (entry.endsWith(languageToLoad + ".qm"))
{
std::unique_ptr<QTranslator> translator = std::make_unique<QTranslator>();
if (translator->load(entry, path))
{
QCoreApplication::installTranslator(translator.get());
d->translators.push_back(std::move(translator));
}
else
{
setErrorString("WARNING! Can't load translate from file: " + entry);
return false;
}
}
}
return true;
}
bool TranslatorStorage::loadQtTranslations(const QString &language, const QString &prefix)
{
return loadTranslators(QString(prefix + "%1").arg(language), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
}
void TranslatorStorage::clearTranslators()
{
for (const auto &translator : d->translators)
{
QCoreApplication::removeTranslator(translator.get());
}
d->translators.clear();
}
void TranslatorStorage::setErrorString(const QString &error)
{
d->m_errorString = error;
}
QString TranslatorStorage::getErrorString() const
{
return d->m_errorString;
}

View File

@ -0,0 +1,89 @@
/***********************************************************************************************************************
**
** Copyright (C) 2022 BaseALT Ltd. <org@basealt.ru>
**
** 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_TRANSLATOR_STORAGE_H
#define GPUI_TRANSLATOR_STORAGE_H
#include "core.h"
#include <memory>
#include <QString>
#include <QTranslator>
class TranslatorStoragePrivate;
/**
* @brief The TranslatorStorage class provides for loading and storing translation files.
*/
class GPUI_CORE_EXPORT TranslatorStorage
{
public:
TranslatorStorage();
~TranslatorStorage();
/**
* @brief loads and install a list of translation files from resources that end with the name of the language from the current directory
* @param language to be loaded
*/
bool loadTranslators(const QString &language);
/**
* @brief loads and installs a list of translation files from resources that end with the name of the language from the specified directory
* @param language to be loaded
* @param path of translation file to be loaded
*/
bool loadTranslators(const QString &language, const QString &path);
/**
* @brief loads and installs a list of translation qt files from resources that begins with prefix and end with the name of the language in current directory
* @param language to be loaded
* @param prefix of the file name to be loaded
*/
bool loadQtTranslations(const QString &language, const QString &prefix);
/**
* @brief removes and uninstalls all translations
*/
void clearTranslators();
/**
* @brief gets a control error string that might be reused in a different context
*/
QString getErrorString() const;
private:
std::unique_ptr<TranslatorStoragePrivate> d;
private:
/**
* @brief sets a control error string that might be reused in a different context
* @param error string
*/
void setErrorString(const QString &error);
private:
TranslatorStorage(const TranslatorStorage &) = delete;
TranslatorStorage(TranslatorStorage &&) = delete;
TranslatorStorage &operator=(const TranslatorStorage &) = delete;
TranslatorStorage &operator=(TranslatorStorage &&) = delete;
};
#endif // GPUI_TRANSLATOR_STORAGE_H

33
src/core/version.h.in Normal file
View File

@ -0,0 +1,33 @@
/***********************************************************************************************************************
**
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
**
** 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 VERSION_H
#define VERSION_H
const int GPUI_VERSION_MAJOR = ${GPUI_VERSION_MAJOR};
const int GPUI_VERSION_MINOR = ${GPUI_VERSION_MINOR};
const int GPUI_VERSION_PATCH = ${GPUI_VERSION_PATCH};
inline QString getApplicationVersion()
{
return QString("%1.%2.%3").arg(GPUI_VERSION_MAJOR).arg(GPUI_VERSION_MINOR).arg(GPUI_VERSION_PATCH);
}
#endif //VERSION_H

View File

@ -4,40 +4,52 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(HEADERS
aboutdialog.h
altspinbox.h
contentwidget.h
commandlineoptions.h
commandlineparser.h
filedialogutils.h
gptiniutil.h
gui.h
listboxdialog.h
mainwindow.h
mainwindowsettings.h
presentationbuilder.h
pluginwidgetinterface.h
treevieweventfilter.h
)
set(SOURCES
aboutdialog.cpp
altspinbox.cpp
commandlineparser.cpp
contentwidget.cpp
filedialogutils.cpp
gptiniutil.cpp
gui.cpp
listboxdialog.cpp
mainwindow.cpp
mainwindowsettings.cpp
presentationbuilder.cpp
treevieweventfilter.cpp
)
set(UI_FORMS
aboutdialog.ui
contentwidget.ui
listboxdialog.ui
mainwindow.ui
mainwindow.ui
)
set(MOC_HEADERS
aboutdialog.h
altspinbox.h
contentwidget.h
gptiniutil.h
listboxdialog.h
mainwindow.h
mainwindowsettings.h
pluginwidgetinterface.h
treevieweventfilter.h
)
set(TS_FILES
@ -60,11 +72,11 @@ add_definitions(
-DGPUI_GUI_LIBRARY
)
add_translation_resource(RESOURCES_SRC ${QM_FILES})
add_translation_resource(RESOURCES_SRC "gui" ${QM_FILES})
qt5_add_resources(LIB_RESOURCES ${RESOURCES_SRC} ${ICON_RESOURCES})
add_gpui_library(gpui-gui ${UI_SOURCES} ${MOC_SOURCES} ${SOURCES} ${LIB_RESOURCES})
target_link_libraries(gpui-gui Qt5::Widgets Qt5::Qml)
target_link_libraries(gpui-gui gpui-model gpui-io)
target_link_libraries(gpui-gui gpui-core gpui-io gpui-ldap)
target_link_libraries(gpui-gui smb-storage-static)

View File

@ -19,17 +19,23 @@
***********************************************************************************************************************/
#include "aboutdialog.h"
#include "../core/version.h"
#include "ui_aboutdialog.h"
namespace gpui
{
AboutDialog::AboutDialog(QWidget* parent)
: QDialog(parent)
, ui(new Ui::AboutDialog())
{
ui->setupUi(this);
QString text = ui->versionLabel->text();
text = text.append(getApplicationVersion());
ui->versionLabel->setText(text);
}
AboutDialog::~AboutDialog()
@ -37,5 +43,4 @@ AboutDialog::~AboutDialog()
delete ui;
}
}

View File

@ -39,6 +39,12 @@ namespace gpui
AboutDialog(QWidget *parent);
~AboutDialog();
private:
AboutDialog(const AboutDialog&) = delete; // copy ctor
AboutDialog(AboutDialog&&) = delete; // move ctor
AboutDialog& operator=(const AboutDialog&) = delete; // copy assignment
AboutDialog& operator=(AboutDialog&&) = delete; // move assignment
private:
Ui::AboutDialog *ui;
};

View File

@ -57,7 +57,7 @@
<item>
<widget class="QLabel" name="versionLabel">
<property name="text">
<string>Version 0.2.0</string>
<string>Version </string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>

112
src/gui/altspinbox.cpp Normal file
View File

@ -0,0 +1,112 @@
/***********************************************************************************************************************
**
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
**
** 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 "altspinbox.h"
#include <QDebug>
#include <QMessageBox>
namespace gui
{
AltSpinBox::AltSpinBox(QWidget *parent)
: QSpinBox(parent)
{
connect(this, &AltSpinBox::fixStringInput, this, &AltSpinBox::onFixStringInput);
connect(this, &AltSpinBox::fixToValidRange, this, &AltSpinBox::onFixToValidRange);
}
void AltSpinBox::fixup(QString &input) const
{
QRegExp regExp("(-?)(\\+?)\\d+");
if (!regExp.exactMatch(input))
{
QSpinBox::fixup(input);
return;
}
bool isOk = false;
int value = input.toInt(&isOk);
if (isOk)
{
int boundValue = qBound(minimum(), value, maximum());
if (boundValue != value)
{
emit fixToValidRange(value, boundValue);
}
}
else
{
emit fixStringInput(input);
}
}
QValidator::State AltSpinBox::validate(QString &text, int &) const
{
auto isOk = false;
auto value = text.toInt(&isOk, displayIntegerBase());
if (isOk)
{
if (value >= minimum() && value <= maximum())
{
return QValidator::Acceptable;
}
}
return QValidator::Intermediate;
}
void AltSpinBox::onFixStringInput(const QString &wrongInput)
{
int value = wrongInput.contains('-') ? this->minimum() : this->maximum();
this->setValue(value);
openMessageBox(wrongInput, value == this->maximum());
}
void AltSpinBox::onFixToValidRange(const int currentValue, const int boundValue)
{
bool isMaximum = boundValue == maximum();
this->setValue(boundValue);
openMessageBox(QString::number(currentValue, displayIntegerBase()), isMaximum);
}
void AltSpinBox::openMessageBox(const QString &value, bool isMaximum)
{
if (isMaximum)
{
QMessageBox::information(nullptr,
QObject::tr("Information message"),
QObject::tr("Value: ") + value
+ QObject::tr(" is greater than maximum allowed value of: ")
+ QString::number(this->maximum())
+ QObject::tr(". Maximum allowed value has been set."),
QMessageBox::Ok);
}
else
{
QMessageBox::information(nullptr,
QObject::tr("Information message"),
QObject::tr("Value: ") + value + QObject::tr(" is less than minimum allowed value of: ")
+ QString::number(this->minimum())
+ QObject::tr(". Minimum allowed value has been set."),
QMessageBox::Ok);
}
}
} // namespace gui

54
src/gui/altspinbox.h Normal file
View File

@ -0,0 +1,54 @@
/***********************************************************************************************************************
**
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
**
** 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_ALT_SPIN_BOX_H
#define GPUI_ALT_SPIN_BOX_H
#include "gui.h"
#include <QSpinBox>
namespace gui
{
class GPUI_GUI_EXPORT AltSpinBox final : public QSpinBox
{
Q_OBJECT
public:
AltSpinBox(QWidget *parent = nullptr);
protected:
void fixup(QString &input) const override;
QValidator::State validate(QString &text, int &pos) const override;
signals:
void fixStringInput(const QString &wrongInput) const;
void fixToValidRange(const int currentValue, const int boundValue) const;
private slots:
void onFixStringInput(const QString &wrongInput);
void onFixToValidRange(const int currentValue, const int boundValue);
private:
void openMessageBox(const QString &value, bool isMaximum);
};
} // namespace gui
#endif //GPUI_ALT_SPIN_BOX_H

View File

@ -23,14 +23,20 @@
#include <QString>
#include <QUuid>
#include <QtMessageHandler>
namespace gpui {
class CommandLineOptions
{
public:
QString policyBundle;
QString path;
};
}
namespace gpui
{
class CommandLineOptions
{
public:
QString path{};
QString policyBundle{};
QString policyName{};
QtMsgType consoleLogLevel{};
QtMsgType syslogLogLevel{};
QtMsgType fileLogLevel{};
};
} // namespace gpui
#endif // GPUI_COMMAND_LINE_OPTIONS_H

View File

@ -20,40 +20,45 @@
#include "commandlineparser.h"
#include <iostream>
#include <memory>
#include <QUuid>
#include <QCommandLineParser>
#include <QTranslator>
#include <QLibraryInfo>
#include <QTranslator>
#include <QUuid>
namespace gpui
{
class CommandLineParserPrivate
{
public:
QApplication& application;
QApplication &application;
std::unique_ptr<QCommandLineParser> parser;
CommandLineParserPrivate(QApplication &application)
: application(application)
{
parser = std::make_unique<QCommandLineParser>();
}
CommandLineParserPrivate(QApplication &currentApplication)
: application(currentApplication)
, parser(std::make_unique<QCommandLineParser>())
{}
private:
CommandLineParserPrivate(const CommandLineParserPrivate &) = delete; // copy ctor
CommandLineParserPrivate(CommandLineParserPrivate &&) = delete; // move ctor
CommandLineParserPrivate &operator=(const CommandLineParserPrivate &) = delete; // copy assignment
CommandLineParserPrivate &operator=(CommandLineParserPrivate &&) = delete; // move assignment
};
CommandLineParser::CommandLineParser(QApplication &application)
: d(new CommandLineParserPrivate(application))
{
}
{}
CommandLineParser::~CommandLineParser()
{
delete d;
}
CommandLineParser::CommandLineParseResult CommandLineParser::parseCommandLine(CommandLineOptions *options, QString *errorMessage)
CommandLineParser::CommandLineParseResult CommandLineParser::parseCommandLine(CommandLineOptions *options,
QString *errorMessage)
{
QLocale locale;
std::unique_ptr<QTranslator> qtTranslator = std::make_unique<QTranslator>();
@ -65,13 +70,55 @@ CommandLineParser::CommandLineParseResult CommandLineParser::parseCommandLine(Co
QCoreApplication::installTranslator(qtTranslator2.get());
const QCommandLineOption pathOption("p", QObject::tr("The full path of policy to edit."), QObject::tr("path"));
const QCommandLineOption bundleOption("b", QObject::tr("The full path of policy bundle to load."), QObject::tr("path"));
const QCommandLineOption bundleOption("b",
QObject::tr("The full path of policy bundle to load."),
QObject::tr("path"));
const QCommandLineOption nameOption("n",
QObject::tr("This options left for compatibility with ADMC. "
"Currently it does nothing."),
QObject::tr("name"));
const QCommandLineOption helpOption(QStringList()
#ifdef Q_OS_WIN
<< QStringLiteral("?")
#endif
<< QStringLiteral("h") << QStringLiteral("help"),
QObject::tr("Displays help on commandline options."));
#ifdef QT_DEBUG
#define CONSOLE_LOG_LEVEL_DEFAULT "debug"
#define SYSLOG_LOG_LEVEL_DEFAULT "none"
#define FILE_LOG_LEVEL_DEFAULT "debug"
#else
#define CONSOLE_LOG_LEVEL_DEFAULT "none"
#define SYSLOG_LOG_LEVEL_DEFAULT "none"
#define FILE_LOG_LEVEL_DEFAULT "warning"
#endif
const QCommandLineOption consoleLogLevelOpion("log-console",
QObject::tr("Set log level for console. ") + QObject::tr("Default")
+ ": \"" CONSOLE_LOG_LEVEL_DEFAULT "\".",
QObject::tr("level"),
CONSOLE_LOG_LEVEL_DEFAULT);
const QCommandLineOption syslogLogLevelOpion("log-syslog",
QObject::tr("Set log level for syslog. ") + QObject::tr("Default")
+ ": \"" SYSLOG_LOG_LEVEL_DEFAULT "\".",
QObject::tr("level"),
SYSLOG_LOG_LEVEL_DEFAULT);
const QCommandLineOption fileLogLevelOpion("log-file",
QObject::tr("Set log level for file in ~/.local/share/gpui/. ")
+ QObject::tr("Default") + ": \"" FILE_LOG_LEVEL_DEFAULT "\".",
QObject::tr("level"),
FILE_LOG_LEVEL_DEFAULT);
d->parser->setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
d->parser->addOption(pathOption);
d->parser->addOption(bundleOption);
d->parser->addOption(helpOption);
d->parser->addOption(nameOption);
d->parser->addOption(consoleLogLevelOpion);
d->parser->addOption(syslogLogLevelOpion);
d->parser->addOption(fileLogLevelOpion);
const QCommandLineOption helpOption = d->parser->addHelpOption();
const QCommandLineOption versionOption = d->parser->addVersionOption();
if (!d->parser->parse(d->application.arguments()))
@ -93,7 +140,7 @@ CommandLineParser::CommandLineParseResult CommandLineParser::parseCommandLine(Co
if (d->parser->isSet(pathOption))
{
const QString path = d->parser->value(pathOption);
options->path = path;
options->path = path;
if (options->path.isNull() || options->path.isEmpty())
{
@ -104,7 +151,7 @@ CommandLineParser::CommandLineParseResult CommandLineParser::parseCommandLine(Co
if (d->parser->isSet(bundleOption))
{
const QString path = d->parser->value(bundleOption);
const QString path = d->parser->value(bundleOption);
options->policyBundle = path;
if (options->policyBundle.isNull() || options->policyBundle.isEmpty())
@ -114,12 +161,59 @@ CommandLineParser::CommandLineParseResult CommandLineParser::parseCommandLine(Co
}
}
if (!handleLoggerOption(consoleLogLevelOpion, options->consoleLogLevel, errorMessage)
|| !handleLoggerOption(syslogLogLevelOpion, options->syslogLogLevel, errorMessage)
|| !handleLoggerOption(fileLogLevelOpion, options->fileLogLevel, errorMessage))
{
return CommandLineError;
}
return CommandLineOk;
}
void CommandLineParser::showHelp() const
bool CommandLineParser::handleLoggerOption(const QCommandLineOption &option, QtMsgType &result, QString *errorMessage)
{
d->parser->showHelp();
if (d->parser->isSet(option))
{
const QString logString = d->parser->value(option);
if (logString == "none")
{
result = LOG_LEVEL_DISABLED;
}
else if (logString == "debug")
{
result = QtDebugMsg;
}
else if (logString == "info")
{
result = QtInfoMsg;
}
else if (logString == "warning")
{
result = QtWarningMsg;
}
else if (logString == "critical")
{
result = QtCriticalMsg;
}
else if (logString == "fatal")
{
result = QtFatalMsg;
}
else
{
*errorMessage = QObject::tr("Bad log level: ") + logString;
return false;
}
}
return true;
}
void CommandLineParser::showHelp(int exitCode) const
{
d->parser->showHelp(exitCode);
}
void CommandLineParser::showVersion() const
@ -127,4 +221,4 @@ void CommandLineParser::showVersion() const
d->parser->showVersion();
}
}
} // namespace gpui

View File

@ -24,6 +24,7 @@
#include "gui.h"
#include "../gui/commandlineoptions.h"
#include "../core/logger/prelude.h"
#include <QApplication>
#include <QCommandLineParser>
@ -48,8 +49,16 @@ namespace gpui {
CommandLineParseResult parseCommandLine(CommandLineOptions *options, QString *errorMessage);
void showHelp() const;
void showVersion() const;
Q_NORETURN void showHelp(int exitCode) const;
Q_NORETURN void showVersion() const;
private:
CommandLineParser(const CommandLineParser&) = delete; // copy ctor
CommandLineParser(CommandLineParser&&) = delete; // move ctor
CommandLineParser& operator=(const CommandLineParser&) = delete; // copy assignment
CommandLineParser& operator=(CommandLineParser&&) = delete; // move assignment
bool handleLoggerOption(const QCommandLineOption &option, QtMsgType &result, QString *errorMessage);
private:
CommandLineParserPrivate* d;

View File

@ -22,41 +22,33 @@
#include "ui_contentwidget.h"
#include "presentationbuilder.h"
#include "../plugins/administrative_templates/admx/policy.h"
#include "../plugins/administrative_templates/admx/policyelement.h"
#include "../plugins/administrative_templates/bundle/itemtype.h"
#include "../plugins/administrative_templates/bundle/policyroles.h"
#include "../plugins/administrative_templates/presentation/presentation.h"
#include "../model/registry/abstractregistrysource.h"
#include "../model/registry/policystatemanager.h"
#include "../model/admx/policy.h"
#include "../model/bundle/policyroles.h"
#include "../model/commands/commandgroup.h"
#include "pluginwidgetinterface.h"
using namespace ::model::bundle;
namespace gpui {
namespace
{
const int LIST_PAGE_INDEX = 0;
const int DATA_PAGE_INDEX = 1;
} // namespace
namespace gpui
{
typedef std::shared_ptr<::model::presentation::Presentation> PresentationPtr;
typedef std::shared_ptr<::model::admx::Policy> PolicyPtr;
class ContentWidgetPrivate
{
public:
model::registry::AbstractRegistrySource* userSource = nullptr;
model::registry::AbstractRegistrySource* machineSource = nullptr;
std::unique_ptr<model::registry::PolicyStateManager> manager;
bool dataChanged = false;
bool stateEnabled = false;
QModelIndex currentIndex;
ContentWidget::PolicyWidgetState state = ContentWidget::PolicyWidgetState::STATE_NOT_CONFIGURED;
QModelIndex currentIndex{};
};
void gpui::ContentWidget::connectDialogBoxSignals()
{
connect(ui->policyStateButtonBox, &QDialogButtonBox::accepted, this, &ContentWidget::onApplyClicked);
connect(ui->policyStateButtonBox, &QDialogButtonBox::rejected, this, &ContentWidget::onCancelClicked);
}
ContentWidget::ContentWidget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::ContentWidget())
@ -64,46 +56,7 @@ ContentWidget::ContentWidget(QWidget *parent)
{
ui->setupUi(this);
setPolicyWidgetsVisible(false);
connect(ui->contentListView, &QListView::clicked, this, &ContentWidget::onListItemClicked);
connect(this, &ContentWidget::modelItemSelected, this, &ContentWidget::onListItemClicked);
connect(ui->notConfiguredRadioButton, &QRadioButton::toggled, this, [=](bool checked) {
if (checked)
{
setPolicyWidgetState(STATE_NOT_CONFIGURED);
qWarning() << "Setting state not configured" << d->manager.get();
if (d->manager)
{
d->manager->setupPolicyState(model::registry::PolicyStateManager::STATE_NOT_CONFIGURED);
}
}
});
connect(ui->enabledRadioButton, &QRadioButton::toggled, this, [=](bool checked) {
if (checked)
{
setPolicyWidgetState(STATE_ENABLED);
qWarning() << "Setting state enabled" << d->manager.get();
if (d->manager)
{
d->manager->setupPolicyState(model::registry::PolicyStateManager::STATE_ENABLED);
}
}
});
connect(ui->disabledRadioButton, &QRadioButton::toggled, this, [=](bool checked) {
if (checked)
{
setPolicyWidgetState(STATE_DISABLED);
qWarning() << "Setting state disabled" << d->manager.get();
if (d->manager)
{
d->manager->setupPolicyState(model::registry::PolicyStateManager::STATE_DISABLED);
}
}
});
connectDialogBoxSignals();
}
ContentWidget::~ContentWidget()
@ -112,181 +65,131 @@ ContentWidget::~ContentWidget()
delete d;
}
void ContentWidget::setModel(QAbstractItemModel* model)
{
ui->contentListView->setModel(model);
}
void ContentWidget::setSelectionModel(QItemSelectionModel* selectionModel)
{
ui->contentListView->setSelectionModel(selectionModel);
}
void ContentWidget::setUserRegistrySource(model::registry::AbstractRegistrySource *registrySource)
{
d->userSource = registrySource;
}
void ContentWidget::setMachineRegistrySource(model::registry::AbstractRegistrySource *registrySource)
{
d->machineSource = registrySource;
}
void ContentWidget::setPolicyWidgetState(ContentWidget::PolicyWidgetState state)
{
switch (state) {
case STATE_ENABLED:
{
d->stateEnabled = true;
ui->contentScrollArea->setDisabled(false);
}break;
case STATE_DISABLED:
case STATE_NOT_CONFIGURED:
default:
d->stateEnabled = false;
ui->contentScrollArea->setDisabled(true);
break;
}
d->state = state;
}
void ContentWidget::onLanguageChaged()
void ContentWidget::onLanguageChanged()
{
ui->retranslateUi(this);
}
void ContentWidget::setEventFilter(QObject *eventFilter)
{
ui->contentListView->installEventFilter(eventFilter);
}
void ContentWidget::setModel(QAbstractItemModel *model)
{
ui->contentListView->setModel(model);
}
void ContentWidget::setSelectionModel(QItemSelectionModel *selectionModel)
{
if (ui->contentListView->selectionModel())
{
disconnect(ui->contentListView->selectionModel());
}
ui->contentListView->setSelectionModel(selectionModel);
connect(ui->contentListView->selectionModel(),
&QItemSelectionModel::selectionChanged,
this,
[&](const QItemSelection &selected, const QItemSelection &deselected) {
Q_UNUSED(deselected);
if (selected.isEmpty() || selected.first().indexes().isEmpty())
{
return;
}
auto modelIndex = selected.first().indexes().first();
ui->descriptionTextEdit->setText(modelIndex.data(PolicyRoles::EXPLAIN_TEXT).toString());
if (modelIndex.data(PolicyRoles::ITEM_TYPE).value<uint>() != ItemType::ITEM_TYPE_POLICY)
{
ui->contentListView->setRootIndex(modelIndex);
}
else
{
if (modelIndex.parent().isValid())
{
ui->contentListView->setRootIndex(modelIndex.parent());
}
}
modelItemSelected(modelIndex);
});
}
void ContentWidget::onListItemClicked(const QModelIndex &index)
{
d->currentIndex = index;
const QAbstractItemModel* model = index.model();
if (d->dataChanged)
{
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, QObject::tr("Save settings dialog"),
QObject::tr("Policy settings were modified do you want to save them?"),
QMessageBox::Yes | QMessageBox::No);
switch (reply)
{
case QMessageBox::Yes:
emit ui->policyStateButtonBox->accepted();
onApplyClicked();
break;
case QMessageBox::No:
onCancelClicked();
break;
default:
break;
}
}
d->dataChanged = false;
if (ui->contentScrollArea->widget()->layout())
{
delete ui->contentScrollArea->takeWidget();
ui->contentScrollArea->setWidget(new QWidget(this));
}
const QAbstractItemModel *model = index.model();
if (model)
{
ui->descriptionTextEdit->setText(model->data(index, PolicyRoles::EXPLAIN_TEXT).value<QString>());
d->manager = nullptr;
auto widget = ui->scrollArea->takeWidget();
if (model->data(index, PolicyRoles::ITEM_TYPE).value<uint>() == 1)
bool deleteWidget = true;
auto pluginWidget = dynamic_cast<gui::PluginWidgetInterface *>(widget);
if (pluginWidget && pluginWidget->hasDataChanged())
{
setPolicyWidgetsVisible(true);
setPolicyWidgetState(STATE_NOT_CONFIGURED);
ui->scrollArea->setWidget(pluginWidget);
setWidgetSignals(pluginWidget);
ui->notConfiguredRadioButton->setChecked(true);
ui->supportedOnTextEdit->setText(model->data(index, PolicyRoles::SUPPORTED_ON).value<QString>());
connect(pluginWidget, &gui::PluginWidgetInterface::rejectPressed, [&deleteWidget]() {
deleteWidget = false;
});
}
auto presentation = model->data(index, PolicyRoles::PRESENTATION).value<PresentationPtr>();
auto policy = model->data(index, PolicyRoles::POLICY).value<PolicyPtr>();
model::registry::AbstractRegistrySource* source = d->userSource;
if (deleteWidget && widget)
{
delete widget;
}
if (policy && d->machineSource)
if (model->data(index, PolicyRoles::ITEM_TYPE).value<uint>() == ItemType::ITEM_TYPE_POLICY)
{
auto policyWidget = model->data(index, PolicyRoles::POLICY_WIDGET).value<std::function<QWidget *()>>();
if (deleteWidget && policyWidget)
{
if (policy->policyType == model::admx::PolicyType::Machine)
{
source = d->machineSource;
}
ui->scrollArea->setWidget(policyWidget());
}
if (source && policy)
{
d->manager = std::make_unique<model::registry::PolicyStateManager>(*source, *policy);
auto state = d->manager->determinePolicyState();
if (state == model::registry::PolicyStateManager::STATE_ENABLED)
{
ui->enabledRadioButton->setChecked(true);
}
if (state == model::registry::PolicyStateManager::STATE_DISABLED)
{
ui->disabledRadioButton->setChecked(true);
}
if (state == model::registry::PolicyStateManager::STATE_NOT_CONFIGURED)
{
ui->notConfiguredRadioButton->setChecked(true);
}
}
if (presentation && policy)
{
ui->policyStateButtonBox->disconnect();
auto layout = ::gui::PresentationBuilder::build({
*presentation, *policy, *source,
*ui->policyStateButtonBox, d->dataChanged,
d->stateEnabled
});
connectDialogBoxSignals();
ui->contentScrollArea->widget()->setLayout(layout);
}
ui->stackedWidget->setCurrentIndex(DATA_PAGE_INDEX);
}
else
{
setPolicyWidgetsVisible(false);
ui->contentListView->setRootIndex(index);
ui->stackedWidget->setCurrentIndex(LIST_PAGE_INDEX);
}
}
}
void ContentWidget::onApplyClicked()
void ContentWidget::setWidgetSignals(gui::PluginWidgetInterface *pluginWidget)
{
d->dataChanged = false;
savePolicyChanges();
QMessageBox messageBox(QMessageBox::Question,
QObject::tr("Save settings dialog"),
QObject::tr("Policy settings were modified do you want to save them?"),
QMessageBox::Yes | QMessageBox::No,
this);
messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
messageBox.setButtonText(QMessageBox::No, tr("No"));
int reply = messageBox.exec();
switch (reply)
{
case QMessageBox::Yes:
emit pluginWidget->acceptPressed();
break;
case QMessageBox::No:
emit pluginWidget->rejectPressed();
break;
default:
break;
}
}
void ContentWidget::onCancelClicked()
{
d->dataChanged = false;
onListItemClicked(d->currentIndex);
}
void gpui::ContentWidget::setPolicyWidgetsVisible(bool visible)
{
ui->supportedOnLabel->setVisible(visible);
ui->supportedOnTextEdit->setVisible(visible);
ui->groupBox->setVisible(visible);
ui->contentScrollArea->setVisible(visible);
ui->contentListView->setVisible(!visible);
ui->policyStateButtonBox->setVisible(visible);
ui->contentWidget->setVisible(visible);
}
}
} // namespace gpui
Q_DECLARE_METATYPE(std::function<QWidget *()>)
Q_DECLARE_METATYPE(std::shared_ptr<::model::presentation::Presentation>)
Q_DECLARE_METATYPE(std::shared_ptr<::model::admx::Policy>)

View File

@ -26,61 +26,71 @@
#include <QtWidgets>
QT_BEGIN_NAMESPACE
namespace Ui { class ContentWidget; }
namespace Ui
{
class ContentWidget;
}
QT_END_NAMESPACE
namespace model {
namespace registry {
class AbstractRegistrySource;
}
namespace model
{
namespace registry
{
class AbstractRegistrySource;
}
} // namespace model
namespace gui
{
class PluginWidgetInterface;
}
namespace gpui {
class ContentWidgetPrivate;
namespace gpui
{
class ContentWidgetPrivate;
class GPUI_GUI_EXPORT ContentWidget : public QWidget {
Q_OBJECT
public:
enum PolicyWidgetState
{
STATE_NOT_CONFIGURED = 0,
STATE_ENABLED = 1,
STATE_DISABLED = 2
};
public:
// construction and destruction
ContentWidget(QWidget *parent = 0);
~ContentWidget();
void setModel(QAbstractItemModel *model);
void setSelectionModel(QItemSelectionModel* selectionModel);
void setUserRegistrySource(model::registry::AbstractRegistrySource* registrySource);
void setMachineRegistrySource(model::registry::AbstractRegistrySource* registrySource);
void setPolicyWidgetState(PolicyWidgetState state);
void onLanguageChaged();
signals:
void modelItemSelected(const QModelIndex& index);
void savePolicyChanges();
private:
Ui::ContentWidget *ui;
ContentWidgetPrivate* d;
private slots:
void onListItemClicked(const QModelIndex &index);
void onApplyClicked();
void onCancelClicked();
private:
void setPolicyWidgetsVisible(bool visible);
void connectDialogBoxSignals();
class GPUI_GUI_EXPORT ContentWidget : public QWidget
{
Q_OBJECT
public:
enum PolicyWidgetState
{
STATE_NOT_CONFIGURED = 0,
STATE_ENABLED = 1,
STATE_DISABLED = 2
};
}
public:
// construction and destruction
ContentWidget(QWidget *parent = 0);
~ContentWidget();
void setEventFilter(QObject *eventFilter);
void setModel(QAbstractItemModel *model);
void setSelectionModel(QItemSelectionModel *selectionModel);
void onLanguageChanged();
signals:
void modelItemSelected(const QModelIndex &index);
private:
Ui::ContentWidget *ui;
ContentWidgetPrivate *d;
private slots:
void onListItemClicked(const QModelIndex &index);
private:
void setWidgetSignals(gui::PluginWidgetInterface *pluginWidget);
private:
ContentWidget(const ContentWidget &) = delete; // copy ctor
ContentWidget(ContentWidget &&) = delete; // move ctor
ContentWidget &operator=(const ContentWidget &) = delete; // copy assignment
ContentWidget &operator=(ContentWidget &&) = delete; // move assignment
};
} // namespace gpui
#endif // GPUI_CONTENT_WIDGET_H

View File

@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>770</width>
<height>488</height>
<width>736</width>
<height>595</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
@ -26,194 +26,126 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QListView" name="contentListView"/>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="contentWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>225</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<item row="0" column="0">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="policyListWidget">
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QListView" name="contentListView">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>4</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Help:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="descriptionTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>4</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>215</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="emptyWidget">
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Policy State</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QRadioButton" name="notConfiguredRadioButton">
<property name="text">
<string>Not Configured</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="enabledRadioButton">
<property name="text">
<string>Enabled</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="disabledRadioButton">
<property name="text">
<string>Disabled</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QScrollArea" name="contentScrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>221</width>
<height>327</height>
</rect>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QWidget" name="rightContainer" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>215</width>
<height>442</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="2" column="0">
<widget class="QTextEdit" name="supportedOnTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="supportedOnLabel">
<property name="text">
<string>Supported on:</string>
</property>
<property name="buddy">
<cstring>supportedOnTextEdit</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="helpLabel">
<property name="text">
<string>Help:</string>
</property>
<property name="buddy">
<cstring>descriptionTextEdit</cstring>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QTextEdit" name="descriptionTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>4</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>215</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QDialogButtonBox" name="policyStateButtonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>736</width>
<height>595</height>
</rect>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>

View File

@ -0,0 +1,88 @@
/***********************************************************************************************************************
**
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
**
** 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 "filedialogutils.h"
#include <QFileDialog>
#include <memory>
namespace gpui
{
bool FileDialogUtils::getOpenFileName(QString& fileName, QWidget *parent, const QString &filter)
{
std::unique_ptr<QFileDialog> fileDialog = std::make_unique<QFileDialog>(parent);
fileDialog->setDirectory(QDir::homePath());
fileDialog->setFileMode(QFileDialog::AnyFile);
fileDialog->setSupportedSchemes(QStringList(QStringLiteral("file")));
fileDialog->setLabelText(QFileDialog::Accept, QObject::tr("Open"));
fileDialog->setLabelText(QFileDialog::FileName, QObject::tr("File name"));
fileDialog->setLabelText(QFileDialog::LookIn, QObject::tr("Look in"));
fileDialog->setLabelText(QFileDialog::Reject, QObject::tr("Cancel"));
fileDialog->setLabelText(QFileDialog::FileType, QObject::tr("File type"));
fileDialog->setNameFilter(filter);
fileDialog->setOptions(QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog);
fileDialog->setWindowTitle(QObject::tr("Open File"));
bool dialogState = fileDialog->exec() == QDialog::Accepted;
if (dialogState)
{
fileName = fileDialog->selectedUrls()[0].toLocalFile();
}
return dialogState;
}
bool FileDialogUtils::getOpenDirectoryName(QString& directoryName, QWidget *parent, const QString &filter)
{
std::unique_ptr<QFileDialog> fileDialog = std::make_unique<QFileDialog>(parent);
fileDialog->setDirectory(QDir::homePath());
fileDialog->setFileMode(QFileDialog::Directory);
fileDialog->setSupportedSchemes(QStringList(QStringLiteral("file")));
fileDialog->setLabelText(QFileDialog::Accept, QObject::tr("Open"));
fileDialog->setLabelText(QFileDialog::FileName, QObject::tr("File name"));
fileDialog->setLabelText(QFileDialog::LookIn, QObject::tr("Look in"));
fileDialog->setLabelText(QFileDialog::Reject, QObject::tr("Cancel"));
fileDialog->setLabelText(QFileDialog::FileType, QObject::tr("File type"));
fileDialog->setNameFilter(filter);
fileDialog->setOptions(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks
| QFileDialog::DontUseNativeDialog);
fileDialog->setWindowTitle(QObject::tr("Open Directory"));
bool dialogState = fileDialog->exec() == QDialog::Accepted;
if (dialogState)
{
directoryName = fileDialog->selectedUrls()[0].toLocalFile();
}
return dialogState;
}
} // namespace gpui

View File

@ -18,27 +18,23 @@
**
***********************************************************************************************************************/
#include "modelbuilder.h"
#ifndef GPUI_FILE_DIALOG_UTILS_H
#define GPUI_FILE_DIALOG_UTILS_H
#include "gui.h"
#include <QWidget>
namespace gpui
{
std::unique_ptr<QStandardItemModel> ModelBuilder::schemaToModel(std::unique_ptr<NetworkShares> &shares)
class GPUI_GUI_EXPORT FileDialogUtils
{
Q_UNUSED(shares);
public:
static bool getOpenFileName(QString &fileName, QWidget *parent = nullptr, const QString &filter = QString());
// TODO: Implement.
static bool getOpenDirectoryName(QString &directoryName, QWidget *parent = nullptr, const QString &filter = QString());
};
return nullptr;
}
} // namespace gpui
std::unique_ptr<NetworkShares> ModelBuilder::modelToSchema(std::unique_ptr<QStandardItemModel> &model)
{
Q_UNUSED(model);
// TODO: Implement.
return nullptr;
}
}
#endif //GPUI_FILE_DIALOG_UTILS_H

206
src/gui/gptiniutil.cpp Normal file
View File

@ -0,0 +1,206 @@
/***********************************************************************************************************************
**
** Copyright (C) 2024 BaseALT Ltd. <org@basealt.ru>
**
** 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 "gptiniutil.h"
#include <QFileDialog>
#include <QDebug>
#include <QMessageBox>
#include <stdexcept>
#include <memory>
#include "../io/genericreader.h"
#include "../io/registryfile.h"
#include "../io/registryfileformat.h"
#include "../io/policydefinitionsfile.h"
#include "../io/policyfileformat.h"
#include "../io/inifile.h"
#include "../plugins/ini/iniformat.h"
#include "../plugins/storage/smb/smbfile.h"
namespace gpui
{
bool GptIniUtils::onIniFileOpen(const QString &path, QString &policyName, int &machineVersion, int &userVersion)
{
qWarning() << "Path recieved: " << path;
auto stringvalues = std::make_unique<std::string>();
try {
if (path.startsWith("smb://"))
{
gpui::smb::SmbFile smbLocationItemFile(path);
smbLocationItemFile.open(QFile::ReadOnly);
stringvalues->resize(smbLocationItemFile.size(), 0);
smbLocationItemFile.read(&stringvalues->at(0), smbLocationItemFile.size());
smbLocationItemFile.close();
}
else
{
QFile registryFile(path);
registryFile.open(QFile::ReadWrite);
stringvalues->resize(registryFile.size(), 0);
registryFile.read(&stringvalues->at(0), registryFile.size());
registryFile.close();
}
auto iss = std::make_unique<std::istringstream>(*stringvalues);
std::string pluginName("ini_ascii");
auto reader = std::make_unique<io::GenericReader>();
auto iniFile = reader->load<io::IniFile, io::PolicyFileFormat<io::IniFile> >(*iss, pluginName);
if (!iniFile)
{
qWarning() << "Unable to load registry file contents.";
return false;
}
auto sections = iniFile->getAllSections();
if (sections->find("General") != sections->end())
{
auto& generalValues = (*sections)["General"];
auto displayName = generalValues.find("displayName");
if (displayName != generalValues.end())
{
policyName = QString::fromStdString(*displayName);
}
auto version = generalValues.find("Version");
if (version != generalValues.end())
{
int intVersion = QString::fromStdString(*version).toInt();
machineVersion = intVersion & 0x0000FFFF;
userVersion = (intVersion & 0xFFFF0000) >> 16;
}
}
return true;
}
catch (std::exception& e)
{
QMessageBox messageBox(QMessageBox::Critical,
QObject::tr("Error"),
QObject::tr("Error reading file:") + "\n" + qPrintable(path),
QMessageBox::Ok,
nullptr);
messageBox.exec();
}
return false;
}
bool GptIniUtils::onIniFileSave(const QString &path, const QString &policyName, const int machineVersion, const int userVersion)
{
std::unique_ptr<io::IniFile> fileData = std::make_unique<io::IniFile>();
fileData->addValue("General", "DisplayName", policyName.toStdString());
int version = (userVersion << 16) + machineVersion;
fileData->addValue("General", "Version", std::to_string(version));
QString pluginName = path;
pluginName = "ini_ascii";
io::PolicyFileFormat<io::IniFile> *format = gpui::PluginStorage::instance()->createPluginClass<io::PolicyFileFormat<io::IniFile>>(pluginName);
if (!format)
{
qWarning() << "Format supporting: " << pluginName << " not found.";
return false;
}
auto oss = std::make_unique<std::ostringstream>();
if (!format->write(*oss, fileData.get()))
{
qWarning() << path << " " << format->getErrorString().c_str();
}
oss->flush();
qWarning() << "Current string values." << oss->str().c_str();
bool ifShowError = false;
auto showMessageFunction = [&path]() {
QMessageBox messageBox(QMessageBox::Critical,
QObject::tr("Error"),
QObject::tr("Error writing file:") + "\n" + qPrintable(path),
QMessageBox::Ok);
messageBox.exec();
};
try
{
if (path.startsWith("smb://"))
{
gpui::smb::SmbFile smbLocationItemFile(path);
ifShowError = smbLocationItemFile.open(QFile::WriteOnly | QFile::Truncate);
if (!ifShowError)
{
ifShowError = smbLocationItemFile.open(QFile::NewOnly | QFile::WriteOnly);
}
if (ifShowError && oss->str().size() > 0)
{
smbLocationItemFile.write(&oss->str().at(0), oss->str().size());
}
smbLocationItemFile.close();
}
else
{
QFile registryFile(path);
ifShowError = registryFile.open(QFile::WriteOnly | QFile::Truncate);
if (!ifShowError)
{
ifShowError = registryFile.open(QFile::NewOnly | QFile::WriteOnly);
}
if (ifShowError && registryFile.isWritable() && oss->str().size() > 0)
{
registryFile.write(&oss->str().at(0), oss->str().size());
}
registryFile.close();
}
}
catch (std::exception &e)
{
ifShowError = true;
showMessageFunction();
return false;
}
if (!ifShowError)
{
showMessageFunction();
}
delete format;
return true;
}
}

40
src/gui/gptiniutil.h Normal file
View File

@ -0,0 +1,40 @@
/***********************************************************************************************************************
**
** Copyright (C) 2024 BaseALT Ltd. <org@basealt.ru>
**
** 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_GPT_INI_UTILS_H
#define GPUI_GPT_INI_UTILS_H
#include "gui.h"
#include <QWidget>
namespace gpui
{
class GPUI_GUI_EXPORT GptIniUtils
{
public:
bool onIniFileOpen(const QString &path, QString& policyName, int& machineVersion, int& userVersion);
bool onIniFileSave(const QString &path, const QString& policyName, const int machineVersion, const int userVersion);
};
} // namespace gpui
#endif //GPUI_GPT_INI_UTILS_H

View File

@ -21,16 +21,15 @@
#ifndef GPUI_GUI_H
#define GPUI_GUI_H
#include "../model/common.h"
#include "../core/common.h"
#ifdef GPUI_GUI_LIBRARY
#define GPUI_GUI_EXPORT GPUI_SYMBOL_EXPORT
#define GPUI_GUI_EXPORT GPUI_SYMBOL_EXPORT
#else
#define GPUI_GUI_EXPORT GPUI_SYMBOL_IMPORT
#define GPUI_GUI_EXPORT GPUI_SYMBOL_IMPORT
#endif
namespace gpui {
}
namespace gpui
{}
#endif // GPUI_GUI_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -40,19 +40,29 @@ ListBoxDialog::ListBoxDialog(const QString &dialogTitle)
connect(ui->newButton, &QPushButton::clicked, this, &ListBoxDialog::onNew);
connect(ui->deleteButton, &QPushButton::clicked, this, &ListBoxDialog::onDelete);
connect(ui->buttonBox, &QDialogButtonBox::accepted, this,
connect(ui->okPushButton, &QPushButton::clicked, this,
[&](){
QStringList items;
QMap<std::string, QString> items;
for(int i = 0; i < ui->tableWidget->rowCount(); ++i)
{
QTableWidgetItem* item = ui->tableWidget->item(i, 1);
if (item && item->data(Qt::DisplayRole).isValid())
QTableWidgetItem* key = ui->tableWidget->item(i, 0);
QTableWidgetItem* value = ui->tableWidget->item(i, 1);
if (value && value->data(Qt::DisplayRole).isValid())
{
items.push_back(item->text());
if (key && key->data(Qt::DisplayRole).isValid())
{
items[key->text().toStdString()] = (value->text());
}
else
{
items[std::to_string(i)] = (value->text());
}
}
}
itemsEditingFinished(items);
});
connect(ui->cancelPushButton, &QPushButton::clicked, this, &ListBoxDialog::close);
connect(ui->okPushButton, &QPushButton::clicked, this, &ListBoxDialog::close);
}
ListBoxDialog::~ListBoxDialog()
@ -63,6 +73,7 @@ ListBoxDialog::~ListBoxDialog()
void ListBoxDialog::setItems(const QStringList &items)
{
int index = 0;
ui->tableWidget->hideColumn(0);
ui->tableWidget->setRowCount(items.size());
for (const auto& itemString : items)
{
@ -71,6 +82,24 @@ void ListBoxDialog::setItems(const QStringList &items)
}
}
void ListBoxDialog::setItems(const QMap<std::string, QString> &items)
{
int index = 0;
ui->tableWidget->showColumn(0);
ui->tableWidget->setRowCount(items.size());
for (const auto& key : items.keys())
{
ui->tableWidget->setItem(index, 0, new QTableWidgetItem(QString::fromStdString(key)));
index++;
}
for (const auto& value : items.values())
{
ui->tableWidget->setItem(index, 1, new QTableWidgetItem(value));
index++;
}
}
void ListBoxDialog::clearItems()
{
ui->tableWidget->clearContents();

View File

@ -24,13 +24,16 @@
#include "gui.h"
#include <QDialog>
#include <QMap>
#include <string>
QT_BEGIN_NAMESPACE
namespace Ui { class ListBoxDialog; }
QT_END_NAMESPACE
namespace gpui {
class ListBoxDialog : public QDialog
class GPUI_GUI_EXPORT ListBoxDialog : public QDialog
{
Q_OBJECT
public:
@ -39,10 +42,11 @@ namespace gpui {
~ListBoxDialog();
void setItems(const QStringList& items);
void setItems(const QMap<std::string, QString>& items);
void clearItems();
signals:
void itemsEditingFinished(QStringList items);
void itemsEditingFinished(QMap<std::string, QString> items);
private:
Ui::ListBoxDialog *ui;
@ -53,6 +57,12 @@ namespace gpui {
private slots:
void onNew();
void onDelete();
private:
ListBoxDialog(const ListBoxDialog&) = delete; // copy ctor
ListBoxDialog(ListBoxDialog&&) = delete; // move ctor
ListBoxDialog& operator=(const ListBoxDialog&) = delete; // copy assignment
ListBoxDialog& operator=(ListBoxDialog&&) = delete; // move assignment
};
}

View File

@ -13,6 +13,9 @@
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="nameLabel">
@ -54,12 +57,16 @@
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<widget class="QPushButton" name="cancelPushButton">
<property name="text">
<string>&amp;Cancel</string>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</widget>
</item>
<item>
<widget class="QPushButton" name="okPushButton">
<property name="text">
<string>&amp;OK</string>
</property>
</widget>
</item>
@ -68,38 +75,5 @@
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ListBoxDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ListBoxDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

View File

@ -19,8 +19,8 @@
***********************************************************************************************************************/
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "mainwindowsettings.h"
#include "ui_mainwindow.h"
#include "aboutdialog.h"
@ -28,10 +28,21 @@
#include "contentwidget.h"
#include "../model/bundle/policybundle.h"
#include "gptiniutil.h"
#include "../model/registry/registry.h"
#include "../model/registry/polregistrysource.h"
#include "treevieweventfilter.h"
#include "../core/isnapin.h"
#include "../core/isnapinmanager.h"
#include "../core/translatorstorage.h"
#include "../plugins/administrative_templates/bundle/itemtype.h"
#include "../plugins/administrative_templates/bundle/policybundle.h"
#include "../plugins/administrative_templates/bundle/policyroles.h"
#include "../plugins/administrative_templates/registry/polregistrysource.h"
#include "../plugins/administrative_templates/registry/registry.h"
#include "../io/registryfileformat.h"
@ -39,142 +50,214 @@
#include "../io/registryfile.h"
#include "../io/registryfileformat.h"
#include "../io/policydefinitionsfile.h"
#include "../io/policyfileformat.h"
#include "../io/inifile.h"
#include "../plugins/storage/smb/smbfile.h"
void registerResources()
#include "../plugins/administrative_templates/bundle/policyroles.h"
#include "../ldap/ldapimpl.h"
#include <stack>
namespace gpui
{
class MainWindowPrivate
{
Q_INIT_RESOURCE(translations);
}
namespace gpui {
class MainWindowPrivate {
public:
std::unique_ptr<QStandardItemModel> model = nullptr;
ContentWidget* contentWidget;
std::unique_ptr<QAbstractItemModel> model = nullptr;
ContentWidget *contentWidget = nullptr;
std::unique_ptr<MainWindowSettings> settings = nullptr;
ISnapInManager *manager = nullptr;
std::shared_ptr<model::registry::Registry> userRegistry;
std::unique_ptr<model::registry::AbstractRegistrySource> userRegistrySource;
QString userRegistryPath;
std::unique_ptr<QSortFilterProxyModel> itemNameSortModel = nullptr;
std::unique_ptr<QSortFilterProxyModel> itemRoleSortModel = nullptr;
std::unique_ptr<QSortFilterProxyModel> searchModel = nullptr;
std::shared_ptr<model::registry::Registry> machineRegistry;
std::unique_ptr<model::registry::AbstractRegistrySource> machineRegistrySource;
QString machineRegistryPath;
std::vector<std::unique_ptr<QTranslator>> translators{};
QString localeName{};
std::unique_ptr<QSortFilterProxyModel> sortModel = nullptr;
QString itemName{};
std::vector<std::unique_ptr<QTranslator>> translators;
QString localeName;
QIcon windowIcon{};
QIcon windowIcon;
CommandLineOptions options{};
CommandLineOptions options;
std::unique_ptr<TreeViewEventFilter> eventFilter = nullptr;
std::unique_ptr<ldap::LDAPContract> ldapImpl = nullptr;
TranslatorStorage *translatorStorage = nullptr;
std::vector<QAction*> languageActions{};
int machineVersion = 0;
int userVersion = 0;
MainWindowPrivate()
: userRegistry(new model::registry::Registry())
, userRegistrySource(new model::registry::PolRegistrySource(userRegistry))
, machineRegistry(new model::registry::Registry())
, machineRegistrySource(new model::registry::PolRegistrySource(machineRegistry))
: eventFilter(new TreeViewEventFilter())
, ldapImpl(new ldap::LDAPImpl())
{}
private:
MainWindowPrivate(const MainWindowPrivate &) = delete; // copy ctor
MainWindowPrivate(MainWindowPrivate &&) = delete; // move ctor
MainWindowPrivate &operator=(const MainWindowPrivate &) = delete; // copy assignment
MainWindowPrivate &operator=(MainWindowPrivate &&) = delete; // move assignment
};
void save(const std::string &fileName, std::shared_ptr<model::registry::Registry> registry)
QModelIndex findParent(QAbstractItemModel *model, const QModelIndex &parent, const QUuid &id)
{
std::unique_ptr<io::RegistryFile> fileData = std::make_unique<io::RegistryFile>();
fileData->setRegistry(registry);
auto stack = std::make_unique<std::stack<QModelIndex>>();
stack->push(parent);
QString pluginName = QString::fromStdString(fileName);
pluginName = pluginName.mid(pluginName.lastIndexOf('.') + 1);
io::RegistryFileFormat<io::RegistryFile>* format = gpui::PluginStorage::instance()->createPluginClass<io::RegistryFileFormat<io::RegistryFile> >(pluginName);
if (!format)
while (!stack->empty())
{
qWarning() << "Format supporting: " << pluginName << " not found.";
auto current = stack->top();
stack->pop();
return;
auto currentId = current.data(model::bundle::CURRENT_UUID).value<QUuid>();
if (currentId == id)
{
return current;
}
for (int row = 0; row < model->rowCount(current); ++row)
{
QModelIndex index = model->index(row, 0, current);
auto indexId = index.data(model::bundle::CURRENT_UUID).value<QUuid>();
if (indexId == id)
{
return index;
}
if (model->hasChildren(index))
{
for (int childRow = 0; childRow < model->rowCount(index); ++childRow)
{
QModelIndex childIndex = model->index(childRow, 0, index);
stack->push(childIndex);
}
}
}
}
auto oss = std::make_unique<std::ostringstream>();
if (!format->write(*oss, fileData.get()))
{
qWarning() << fileName.c_str() << " " << format->getErrorString().c_str();
}
oss->flush();
qWarning() << "Current string values." << oss->str().c_str();
if (QString::fromStdString(fileName).startsWith("smb://"))
{
gpui::smb::SmbFile smbLocationItemFile(QString::fromStdString(fileName));
bool isOpen = smbLocationItemFile.open(QFile::WriteOnly | QFile::Truncate);
if (!isOpen)
{
isOpen = smbLocationItemFile.open(QFile::NewOnly | QFile::WriteOnly);
}
if (isOpen && oss->str().size() > 0)
{
smbLocationItemFile.write(&oss->str().at(0), oss->str().size());
}
smbLocationItemFile.close();
}
else
{
QFile registryFile(QString::fromStdString(fileName));
registryFile.open(QFile::WriteOnly | QFile::Truncate);
if (!registryFile.isOpen())
{
registryFile.open(QFile::NewOnly | QFile::WriteOnly);
}
if (registryFile.isOpen() && registryFile.isWritable() && oss->str().size() > 0)
{
registryFile.write(&oss->str().at(0), oss->str().size());
}
registryFile.close();
}
delete format;
return QModelIndex();
}
MainWindow::MainWindow(CommandLineOptions &options, QWidget *parent)
void appendModel(QStandardItem *target, const QAbstractItemModel *model, const QModelIndex &parent)
{
for (int rowIndex = 0; rowIndex < model->rowCount(parent); ++rowIndex)
{
QModelIndex index = model->index(rowIndex, 0, parent);
auto parentId = index.data(model::bundle::PARENT_UUID).value<QUuid>();
auto parentIndex = QModelIndex();
auto currentId = index.data(model::bundle::CURRENT_UUID).value<QUuid>();
auto currentIndex = findParent(target->model(), target->model()->index(0, 0).parent(), currentId);
QStandardItem *child = nullptr;
if (!currentIndex.isValid())
{
if (!currentId.isNull())
{
qWarning() << "Current id: " << currentId;
}
if (!parentId.isNull())
{
qWarning() << "Non null uuid" << index.data() << parentId;
parentIndex = findParent(target->model(), target->model()->index(0, 0), parentId);
}
child = new QStandardItem();
child->setData(index.data(Qt::DisplayRole), Qt::DisplayRole);
child->setData(index.data(Qt::DecorationRole), Qt::DecorationRole);
child->setData(index.data(model::bundle::ITEM_TYPE), model::bundle::ITEM_TYPE);
child->setData(index.data(model::bundle::EXPLAIN_TEXT), model::bundle::EXPLAIN_TEXT);
child->setData(index.data(model::bundle::SUPPORTED_ON), model::bundle::SUPPORTED_ON);
child->setData(index.data(model::bundle::PRESENTATION), model::bundle::PRESENTATION);
child->setData(index.data(model::bundle::POLICY), model::bundle::POLICY);
child->setData(index.data(model::bundle::POLICY_TYPE), model::bundle::POLICY_TYPE);
child->setData(index.data(model::bundle::POLICY_WIDGET), model::bundle::POLICY_WIDGET);
child->setData(index.data(model::bundle::CURRENT_UUID), model::bundle::CURRENT_UUID);
child->setData(index.data(model::bundle::PARENT_UUID), model::bundle::PARENT_UUID);
if (parentIndex.isValid())
{
qWarning() << "Found valid index" << parentIndex.data();
target->model()->itemFromIndex(parentIndex)->appendRow(child);
}
else
{
target->insertRow(rowIndex, child);
}
}
else
{
child = target->model()->itemFromIndex(currentIndex);
}
if (model->hasChildren(index))
{
appendModel(child, model, index);
}
}
}
MainWindow::MainWindow(CommandLineOptions &options,
ISnapInManager *manager,
TranslatorStorage *translatorStorage,
QWidget *parent)
: QMainWindow(parent)
, d(new MainWindowPrivate())
, ui(new Ui::MainWindow())
{
registerResources();
d->manager = manager;
d->options = options;
d->translatorStorage = translatorStorage;
ui->setupUi(this);
ui->treeView->installEventFilter(d->eventFilter.get());
d->ldapImpl->initialize();
d->settings = std::make_unique<MainWindowSettings>(this, ui);
d->settings->restoreSettings();
createLanguageMenu();
d->contentWidget = new ContentWidget(this);
d->contentWidget->setMachineRegistrySource(d->machineRegistrySource.get());
d->contentWidget->setUserRegistrySource(d->userRegistrySource.get());
d->contentWidget->setEventFilter(d->eventFilter.get());
ui->splitter->addWidget(d->contentWidget);
connect(ui->actionOpenPolicyDirectory, &QAction::triggered, this, &MainWindow::onDirectoryOpen);
connect(ui->actionSaveRegistrySource, &QAction::triggered, this, &MainWindow::onRegistrySourceSave);
connect(ui->treeView, &QTreeView::clicked, d->contentWidget, &ContentWidget::modelItemSelected);
connect(d->eventFilter.get(), &TreeViewEventFilter::onEnter, this, [&]() {
ui->treeView->clicked(ui->treeView->currentIndex());
});
QLocale locale(!d->localeName.trimmed().isEmpty() ? d->localeName.replace("-","_") : "");
std::unique_ptr<QTranslator> qtTranslator = std::make_unique<QTranslator>();
qtTranslator->load(locale, "gui", "_", ":/");
QCoreApplication::installTranslator(qtTranslator.get());
d->translators.push_back(std::move(qtTranslator));
d->localeName = locale.name().replace("_","-");
d->contentWidget->onLanguageChaged();
connect(ui->actionOpenPolicyDirectory, &QAction::triggered, this, &MainWindow::onDirectoryOpen);
connect(ui->actionSaveRegistrySource, &QAction::triggered, this, &MainWindow::updateStatusBar);
connect(ui->treeView, &QTreeView::clicked, d->contentWidget, &ContentWidget::modelItemSelected);
connect(d->contentWidget, &ContentWidget::modelItemSelected, [&](const QModelIndex &current) {
d->itemName = current.data().toString();
});
QLocale locale(!d->localeName.trimmed().isEmpty() ? d->localeName.replace("-", "_")
: QLocale::system().name().replace("-", "_"));
QString language = locale.name().split("_").at(0);
loadTranslations(language);
d->localeName = locale.name().replace("_", "-");
d->contentWidget->onLanguageChanged();
ui->retranslateUi(this);
retranslateLanguageActions();
d->windowIcon = QIcon(":gpui.png");
@ -185,27 +268,44 @@ MainWindow::MainWindow(CommandLineOptions &options, QWidget *parent)
d->options.policyBundle = "/usr/share/PolicyDefinitions";
}
loadPolicyBundleFolder(d->options.policyBundle, d->localeName);
if (d->options.path.isEmpty())
{
d->options.path = QDir::currentPath();
}
for (auto &snapIn : manager->getSnapIns())
{
qWarning() << "Loading model from: " << snapIn->getDisplayName();
snapIn->onInitialize(this);
}
if (!d->options.path.isEmpty())
{
d->userRegistryPath = d->options.path + "/User/Registry.pol";
d->machineRegistryPath = d->options.path + "/Machine/Registry.pol";
onPolFileOpen(d->userRegistryPath, d->userRegistry, d->userRegistrySource,
[&](model::registry::AbstractRegistrySource* source)
for (auto &snapIn : manager->getSnapIns())
{
d->contentWidget->setUserRegistrySource(source);
});
onPolFileOpen(d->machineRegistryPath, d->machineRegistry, d->machineRegistrySource,
[&](model::registry::AbstractRegistrySource* source)
{
d->contentWidget->setMachineRegistrySource(source);
});
snapIn->onDataLoad(d->options.path.toStdString(), d->localeName.toStdString());
}
}
connect(d->contentWidget, &ContentWidget::savePolicyChanges, this, &MainWindow::onRegistrySourceSave);
QString guid = isAnyGUID(d->options.path);
qWarning() << "Guid: " << guid;
if (guid != "")
{
d->options.policyName = d->ldapImpl.get()->getDisplayNameGPO(guid);
int version = d->ldapImpl->getGPOVersion(guid);
d->machineVersion = version & 0x0000FFFF;
d->userVersion = (version & 0xFFFF0000) >> 16;
}
loadPolicyModel(manager);
connect(ui->searchLineEdit, &QLineEdit::textChanged, [&](const QString &text) {
d->searchModel->setFilterFixedString(text);
});
}
MainWindow::~MainWindow()
@ -228,6 +328,7 @@ QString MainWindow::getLanguage() const
void MainWindow::setAdmxPath(const QString &admxPath)
{
d->options.policyBundle = admxPath;
admxPathChanged(admxPath);
}
QString MainWindow::getAdmxPath() const
@ -235,6 +336,11 @@ QString MainWindow::getAdmxPath() const
return d->options.policyBundle;
}
QString MainWindow::getPolicyName() const
{
return d->options.policyName;
}
void MainWindow::closeEvent(QCloseEvent *event)
{
d->settings->saveSettings();
@ -242,28 +348,98 @@ void MainWindow::closeEvent(QCloseEvent *event)
QMainWindow::closeEvent(event);
}
void gpui::MainWindow::loadPolicyBundleFolder(const QString& path, const QString &locale)
void MainWindow::loadPolicyModel(ISnapInManager *manager)
{
auto bundle = std::make_unique<model::bundle::PolicyBundle>();
d->model = bundle->loadFolder(path.toStdString(), locale.toStdString());
auto concatenateRowsModel = std::make_unique<QStandardItemModel>();
d->sortModel = std::make_unique<QSortFilterProxyModel>();
d->sortModel->setSourceModel(d->model.get());
d->sortModel->setSortLocaleAware(true);
d->sortModel->setSortRole(Qt::DisplayRole);
d->sortModel->sort(0);
QStandardItem *rootItem = concatenateRowsModel->invisibleRootItem();
rootItem->setData("Root Item", Qt::DisplayRole);
ui->treeView->setModel(d->sortModel.get());
d->contentWidget->setModel(d->sortModel.get());
QStandardItem *visibleRootItem = new QStandardItem();
visibleRootItem->setData(QIcon::fromTheme("text-x-generic-template"), Qt::DecorationRole);
visibleRootItem->setData(static_cast<uint>(model::bundle::ItemType::ITEM_TYPE_CATEGORY), model::bundle::ITEM_TYPE);
visibleRootItem->setData(QObject::tr("Local group policies"), model::bundle::EXPLAIN_TEXT);
visibleRootItem->setData(static_cast<uint>(model::admx::PolicyType::Both), model::bundle::POLICY_TYPE);
QString adjustedPolicyName = d->options.policyName.isEmpty()
? d->options.policyName
: QString(" - %1").arg(d->options.policyName);
if (d->options.path.startsWith("smb://"))
{
QRegExp domainRegexp("^(?:smb?:\\/\\/)?([^:\\/\\n?]+)");
if (domainRegexp.indexIn(d->options.path) != -1)
{
visibleRootItem->setData('[' + domainRegexp.cap() + ']' + adjustedPolicyName, Qt::DisplayRole);
}
else
{
visibleRootItem->setData(QObject::tr("[Domain Group Policy]") + adjustedPolicyName, Qt::DisplayRole);
}
}
else
{
visibleRootItem->setData(QObject::tr("[Local Group Policy]") + adjustedPolicyName, Qt::DisplayRole);
}
rootItem->appendRow(visibleRootItem);
for (auto &snapIn : manager->getSnapIns())
{
if (snapIn->getRootNode())
{
QAbstractItemModel *snapInModel = snapIn->getRootNode();
qWarning() << "Appending model from: " << snapIn->getDisplayName();
appendModel(visibleRootItem, snapInModel, snapInModel->index(0, 0));
}
}
d->model = std::move(concatenateRowsModel);
d->itemNameSortModel = std::make_unique<QSortFilterProxyModel>();
d->itemNameSortModel->setSourceModel(d->model.get());
d->itemNameSortModel->setSortLocaleAware(true);
d->itemNameSortModel->setSortRole(Qt::DisplayRole);
d->itemNameSortModel->sort(0);
d->itemRoleSortModel = std::make_unique<QSortFilterProxyModel>();
d->itemRoleSortModel->setSourceModel(d->itemNameSortModel.get());
d->itemRoleSortModel->setSortRole(model::bundle::PolicyRoles::ITEM_TYPE);
d->itemRoleSortModel->sort(0);
d->searchModel = std::make_unique<QSortFilterProxyModel>();
d->searchModel->setSourceModel(d->itemRoleSortModel.get());
d->searchModel->setFilterRole(Qt::DisplayRole);
d->searchModel->setFilterFixedString("");
d->searchModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
d->searchModel->setRecursiveFilteringEnabled(true);
ui->treeView->setModel(d->searchModel.get());
ui->treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
d->contentWidget->setModel(d->searchModel.get());
d->contentWidget->setSelectionModel(ui->treeView->selectionModel());
d->contentWidget->modelItemSelected(d->sortModel->index(0, 0));
ui->treeView->expand(d->searchModel->index(0, 0));
ui->treeView->setColumnHidden(1, true);
d->contentWidget->modelItemSelected(d->searchModel->index(0, 0));
int gptIniMachineVersion = 0;
int gptIniUserVersion = 0;
QString gptIniPolicyName;
GptIniUtils gptUtils;
gptUtils.onIniFileOpen(d->options.path + "/gpt.ini", gptIniPolicyName, gptIniMachineVersion, gptIniUserVersion);
d->machineVersion = d->machineVersion >= gptIniMachineVersion ? d->machineVersion : gptIniMachineVersion;
d->userVersion = d->userVersion >= gptIniUserVersion ? d->userVersion : gptIniUserVersion;
}
void MainWindow::onDirectoryOpen()
{
{
std::unique_ptr<QFileDialog> fileDialog = std::make_unique<QFileDialog>(this);
fileDialog->setDirectory(QDir::homePath());
@ -274,10 +450,10 @@ void MainWindow::onDirectoryOpen()
fileDialog->setLabelText(QFileDialog::FileName, tr("File name"));
fileDialog->setLabelText(QFileDialog::LookIn, tr("Look in"));
fileDialog->setLabelText(QFileDialog::Reject, tr("Cancel"));
fileDialog->setLabelText(QFileDialog::FileType, tr("File type"));
fileDialog->setNameFilter(QObject::tr("All files (*.*)"));
fileDialog->setOptions(QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks
fileDialog->setOptions(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks
| QFileDialog::DontUseNativeDialog);
fileDialog->setWindowIcon(d->windowIcon);
@ -285,32 +461,48 @@ void MainWindow::onDirectoryOpen()
if (fileDialog->exec() == QDialog::Accepted)
{
d->options.policyBundle = fileDialog->selectedUrls().value(0).toLocalFile();
loadPolicyBundleFolder(d->options.policyBundle, d->localeName);
setAdmxPath(fileDialog->selectedUrls().value(0).toLocalFile());
loadPolicyModel(d->manager);
}
}
void MainWindow::onRegistrySourceSave()
void MainWindow::updateStatusBar()
{
if (!d->machineRegistryPath.isEmpty())
QString guid = isAnyGUID(d->options.path);
const QString preferecnes {
"[{5794DAFD-BE60-433f-88A2-1A31939AC01F}{2EA1A81B-48E5-45E9-8BB7-A6E3AC170006}]" // Preference CSE GUID Drives
"[{0E28E245-9368-4853-AD84-6DA3BA35BB75}{35141B6B-498A-4CC7-AD59-CEF93D89B2CE}]" // Preference CSE GUID Environment Variables
"[{7150F9BF-48AD-4da4-A49C-29EF4A8369BA}{3BAE7E51-E3F4-41D0-853D-9BB9FD47605F}]" // Preference CSE GUID Files
"[{6232C319-91AC-4931-9385-E70C2B099F0E}{3EC4E9D3-714D-471F-88DC-4DD4471AAB47}]" // Preference CSE GUID Folders
"[{74EE6C03-5363-4554-B161-627540339CAB}{516FC620-5D34-4B08-8165-6A06B623EDEB}]" // Preference CSE GUID Ini Files
"[{6A4C88C6-C502-4f74-8F60-2CB23EDC24E2}{BFCBBEB0-9DF4-4c0c-A728-434EA66A0373}]" // Preference CSE GUID Network Shares
"[{B087BE9D-ED37-454f-AF9C-04291E351182}{BEE07A6A-EC9F-4659-B8C9-0B1937907C83}]" // Preference CSE GUID Registry
"[{6A4C88C6-C502-4f74-8F60-2CB23EDC24E2}{BFCBBEB0-9DF4-4c0c-A728-434EA66A0373}]" // Preference CSE GUID Network Shares";
};
const QString machineAdministrativeTemplates = "[{35378EAC-683F-11D2-A89A-00C04FBBCFA2}{D02B1F72-3407-48AE-BA88-E8213C6761F1}]";
const QString machineScripts = "[{42B5FAAE-6536-11d2-AE5A-0000F87571E3}{40B6664F-4972-11D1-A7CA-0000F87571E3}]";
const QString userAdministrativeTemplates = "[{35378EAC-683F-11D2-A89A-00C04FBBCFA2}{D02B1F73-3407-48AE-BA88-E8213C6761F1}]";
const QString userScripts = "[{42B5FAAE-6536-11d2-AE5A-0000F87571E3}{40B66650-4972-11D1-A7CA-0000F87571E3}]";
QString machineExtensions = machineAdministrativeTemplates + preferecnes + machineScripts;
QString userExtensions = userAdministrativeTemplates + preferecnes + userScripts;
++d->machineVersion;
++d->userVersion;
if (guid != "")
{
qWarning() << "Saving machine registry to: " << d->machineRegistryPath;
save(d->machineRegistryPath.toStdString(), d->machineRegistry);
}
else
{
qWarning() << "Unable to save machine registry path is empty!";
d->ldapImpl->setExtensions(guid, machineExtensions, userExtensions, d->machineVersion, d->userVersion);
}
if (!d->userRegistryPath.isEmpty())
{
qWarning() << "Saving user registry to: " << d->userRegistryPath;
save(d->userRegistryPath.toStdString(), d->userRegistry);
}
else
{
qWarning() << "Unable to save user registry path is empty!";
}
GptIniUtils gptUtils;
gptUtils.onIniFileSave(d->options.path + "/gpt.ini", d->options.policyName, d->machineVersion, d->userVersion);
ui->statusbar->showMessage(tr("Applied changes for policy: ") + d->itemName);
}
void MainWindow::on_actionExit_triggered()
@ -320,7 +512,9 @@ void MainWindow::on_actionExit_triggered()
void MainWindow::on_actionManual_triggered()
{
const QUrl manual_url = QUrl("https://www.altlinux.org/%D0%93%D1%80%D1%83%D0%BF%D0%BF%D0%BE%D0%B2%D1%8B%D0%B5_%D0%BF%D0%BE%D0%BB%D0%B8%D1%82%D0%B8%D0%BA%D0%B8/GPUI");
const QUrl manual_url = QUrl("https://www.altlinux.org/"
"%D0%93%D1%80%D1%83%D0%BF%D0%BF%D0%BE%D0%B2%D1%8B%D0%B5_%D0%BF%D0%"
"BE%D0%BB%D0%B8%D1%82%D0%B8%D0%BA%D0%B8/GPUI");
QDesktopServices::openUrl(manual_url);
}
@ -330,88 +524,46 @@ void MainWindow::on_actionAbout_triggered()
about->show();
}
void gpui::MainWindow::retranslateLanguageActions()
{
for (auto& languageAction : d->languageActions)
{
languageAction->setText(selectTranslationForLanguageName(languageAction->data().toString()));
}
}
void MainWindow::onLanguageChanged(QAction *action)
{
for (const auto& translator : d->translators)
{
qApp->removeTranslator(translator.get());
}
d->translators.clear();
d->translatorStorage->clearTranslators();
QString language = action->data().toString();
std::unique_ptr<QTranslator> qtTranslator = std::make_unique<QTranslator>();
bool loadResult = qtTranslator->load("gui_" + language + ".qm", ":/");
QCoreApplication::installTranslator(qtTranslator.get());
d->translators.push_back(std::move(qtTranslator));
qWarning() << "Load language " << language << loadResult;
loadTranslations(language);
QLocale locale(language);
d->localeName = locale.name().replace("_", "-");
loadPolicyBundleFolder(d->options.policyBundle, d->localeName);
for (auto &snapIn : d->manager->getSnapIns())
{
snapIn->onRetranslateUI(d->localeName.toStdString());
qWarning() << d->localeName;
}
d->contentWidget->onLanguageChaged();
d->contentWidget->onLanguageChanged();
ui->retranslateUi(this);
loadPolicyModel(d->manager);
ui->treeView->selectionModel()->clearSelection();
}
void MainWindow::onPolFileOpen(const QString &path,
std::shared_ptr<model::registry::Registry> &registry,
std::unique_ptr<model::registry::AbstractRegistrySource> &source,
std::function<void (model::registry::AbstractRegistrySource *)> callback)
{
qWarning() << "Path recieved: " << path;
ui->searchLineEdit->clear();
auto stringvalues = std::make_unique<std::string>();
try {
if (path.startsWith("smb://"))
{
gpui::smb::SmbFile smbLocationItemFile(path);
smbLocationItemFile.open(QFile::ReadOnly);
stringvalues->resize(smbLocationItemFile.size(), 0);
smbLocationItemFile.read(&stringvalues->at(0), smbLocationItemFile.size());
smbLocationItemFile.close();
}
else
{
QFile registryFile(path);
registryFile.open(QFile::ReadWrite);
stringvalues->resize(registryFile.size(), 0);
registryFile.read(&stringvalues->at(0), registryFile.size());
registryFile.close();
}
auto iss = std::make_unique<std::istringstream>(*stringvalues);
std::string pluginName("pol");
auto reader = std::make_unique<io::GenericReader>();
auto registryFile = reader->load<io::RegistryFile, io::RegistryFileFormat<io::RegistryFile> >(*iss, pluginName);
if (!registryFile)
{
qWarning() << "Unable to load registry file contents.";
return;
}
registry = registryFile->getRegistry();
source = std::make_unique<model::registry::PolRegistrySource>(registry);
callback(source.get());
}
catch (std::exception& e)
{
qWarning() << "Unable to read file: " << qPrintable(path) << " Error: " << e.what();
}
retranslateLanguageActions();
}
void MainWindow::createLanguageMenu()
{
QActionGroup* langGroup = new QActionGroup(this);
QActionGroup *langGroup = new QActionGroup(this);
langGroup->setExclusive(true);
connect(langGroup, &QActionGroup::triggered, this, &MainWindow::onLanguageChanged);
@ -420,7 +572,7 @@ void MainWindow::createLanguageMenu()
QDir dir(":/");
QStringList fileNames = dir.entryList(QStringList("gui_*.qm"));
QMenu* menu = new QMenu(this);
QMenu *menu = new QMenu(this);
ui->actionLanguage->setMenu(menu);
for (QString locale : fileNames)
@ -441,7 +593,69 @@ void MainWindow::createLanguageMenu()
{
action->setChecked(true);
}
d->languageActions.emplace_back(action);
}
}
QString MainWindow::isAnyGUID(QString &path)
{
QRegExp lastPartOfPath("/\\{([^/]+)\\}/?$");
QRegExp regExpGuid("^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})$");
qWarning() << lastPartOfPath.indexIn(path);
if (lastPartOfPath.indexIn(path) != -1)
{
QStringList lastPart = lastPartOfPath.capturedTexts();
QString preGuid = lastPart[lastPart.size() - 1];
if (regExpGuid.indexIn(preGuid) != -1)
{
return preGuid;
}
else
{
return QString();
}
}
else
{
return QString();
}
}
void MainWindow::loadTranslations(QString &language)
{
d->translatorStorage->clearTranslators();
d->translatorStorage->loadTranslators(language);
d->translatorStorage->loadQtTranslations(language, QString("qtbase_%2").arg(language));
d->translatorStorage->loadQtTranslations(language, "qt_");
}
QString MainWindow::selectTranslationForLanguageName(const QString &name)
{
qWarning() << "Trying to select name for language: " << name;
if (name.compare("en") == 0)
{
return QObject::tr("English");
}
if (name.compare("ru") == 0)
{
return QObject::tr("Russian");
}
return "";
}
void MainWindow::updateFilterModel()
{
loadPolicyModel(d->manager);
}
} // namespace gpui

View File

@ -23,69 +23,109 @@
#include "gui.h"
#include "../core/translatorstorage.h"
#include <QtWidgets>
#include "../ldap/ldapcontract.h"
#include "../ldap/ldapimpl.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
namespace Ui
{
class MainWindow;
}
QT_END_NAMESPACE
namespace model {
namespace registry {
class AbstractRegistrySource;
class Registry;
}
}
namespace model
{
namespace registry
{
class AbstractRegistrySource;
class Registry;
} // namespace registry
} // namespace model
namespace gpui {
namespace gpui
{
class CommandLineOptions;
class MainWindowPrivate;
class ISnapInManager;
class ISnapIn;
class CommandLineOptions;
class MainWindowPrivate;
class GPUI_GUI_EXPORT MainWindow : public QMainWindow
{
Q_OBJECT
public:
// construction and destruction
MainWindow(CommandLineOptions &options,
ISnapInManager *manager,
TranslatorStorage *translatorStorage,
QWidget *parent = 0);
~MainWindow();
class GPUI_GUI_EXPORT MainWindow : public QMainWindow {
Q_OBJECT
void setLanguage(const QString &language);
QString getLanguage() const;
public:
// construction and destruction
MainWindow(CommandLineOptions& options, QWidget *parent = 0);
~MainWindow();
void setAdmxPath(const QString &admxPath);
QString getAdmxPath() const;
void setLanguage(const QString& language);
QString getLanguage() const;
QString getPolicyName() const;
void setAdmxPath(const QString& admxPath);
QString getAdmxPath() const;
signals:
void admxPathChanged(const QString &admxPath);
protected:
void closeEvent(QCloseEvent *event) override;
public slots:
void updateStatusBar();
private slots:
void on_actionManual_triggered();
void updateFilterModel();
private:
protected:
void closeEvent(QCloseEvent *event) override;
MainWindowPrivate* const d;
private slots:
void on_actionManual_triggered();
Ui::MainWindow *ui;
private:
MainWindowPrivate *const d;
private slots:
void onDirectoryOpen();
void onRegistrySourceSave();
Ui::MainWindow *ui;
void on_actionExit_triggered();
void on_actionAbout_triggered();
private slots:
void onDirectoryOpen();
void onLanguageChanged(QAction *action);
void on_actionExit_triggered();
void on_actionAbout_triggered();
private:
void onPolFileOpen(const QString& path,
std::shared_ptr<model::registry::Registry>& registry,
std::unique_ptr<model::registry::AbstractRegistrySource>& source,
std::function<void(model::registry::AbstractRegistrySource* source)> callback);
void onLanguageChanged(QAction *action);
void loadPolicyBundleFolder(const QString& path, const QString& locale);
private:
void onIniFileOpen(const QString &path);
void createLanguageMenu();
};
}
void loadPolicyModel(ISnapInManager *manager);
void createLanguageMenu();
QString isAnyIPAddress(const QString &path);
QString isAnyDomainName(const QString &path);
QString isAnyGUID(const QString &path);
void loadTranslations(QString &language);
QString selectTranslationForLanguageName(const QString& name);
void retranslateLanguageActions();
private:
MainWindow(const MainWindow &) = delete; // copy ctor
MainWindow(MainWindow &&) = delete; // move ctor
MainWindow &operator=(const MainWindow &) = delete; // copy assignment
MainWindow &operator=(MainWindow &&) = delete; // move assignment
private:
QString isAnyGUID(QString &path);
};
} // namespace gpui
#endif // GPUI_MAINWINDOW_H

Some files were not shown because too many files have changed in this diff Show More