Сделал оболочку

pull/3/head
Igor Belitskiy 2 years ago
parent 47bdc83fd7
commit bc73285ea3

1
.gitignore vendored

@ -0,0 +1 @@
.vscode/

@ -0,0 +1,157 @@
#!/usr/bin/make -f
#SHELL := /bin/bash
MAKEFILE_FILEPATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MAKEFILE_DIR := $(notdir $(patsubst %/,%,$(dir $(MAKEFILE_FILEPATH))))
MAKEFILE_PATH := $(dir $(MAKEFILE_FILEPATH))
CMAKE_COMMAND = cmake
CMAKE_SOURCE_DIR = $(MAKEFILE_PATH)source
CMAKE_BUILD_DIR = $(MAKEFILE_PATH)compile
#CMAKE_SOURCE_DIR = ./source
#CMAKE_BUILD_DIR = ./compile
FILE_VERSION = VERSION.md
DEPENDS = /bin/cmake
PREFIX ?= /usr
PKGNAME = $(MAKEFILE_DIR)
#PKGNAME = ubl-settings-manager
default_target: all
.PHONY: all init depend debug prepare check build uninstall install clean up_ver help
all: init build
init:
@echo "Initialize ..."; \
sed -r "s/(version_application = ).*/\1\"$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2)\";/" -i source/ubl-settings-quotas.cc; \
echo "-- Build path: ${CMAKE_BUILD_DIR}"
depend:
@echo "Check depends ..."
@for FILE_DEPEND in $(DEPENDS); do \
if [ ! -f $${FILE_DEPEND} ]; then \
echo "ERROR: Depend '$${FILE_DEPEND}' not found !"; \
exit 1; \
fi; \
done; \
echo "Check depends: OK"
# $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
debug:
@echo "Debug ..."
if [ ! -d ${CMAKE_BUILD_DIR} ]; then \
$(CMAKE_COMMAND) -S${CMAKE_SOURCE_DIR} -B${CMAKE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="${PREFIX}"; \
fi; \
echo "Debug: OK"
prepare:
@echo "Prepare ..."; \
if [ ! -d ${CMAKE_BUILD_DIR} ]; then \
$(CMAKE_COMMAND) -S${CMAKE_SOURCE_DIR} -B${CMAKE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${PREFIX}"; \
fi; \
echo "Prepare: OK"
check:
@echo "Check ..."; \
if [ -f ${CMAKE_BUILD_DIR}/${PKGNAME} ]; then \
echo "Check: OK"; \
else \
echo "Check: ${CMAKE_BUILD_DIR}/${PKGNAME} not found !"; \
exit 1; \
fi
build: depend prepare
@echo "Build ..."; \
make --directory=${CMAKE_BUILD_DIR}; \
echo "Build: OK"
uninstall:
@echo "Uninstall ..."
@for FILE_PO in $(wildcard *.po); do \
LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \
FILE_MO=$${FILE_PO##*/}; FILE_MO="$${FILE_MO%_*.po}.mo"; \
PATH_FILE_MO="${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \
$(RM) "$${PATH_FILE_MO}"; \
done
@for SIZE in 16x16 32x32 48x48 scalable; do \
$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \
$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/apps/com.ublinux.${PKGNAME}.png"; \
done
@for FILE_SVG in $(wildcard *.svg); do \
for SIZE in 16x16 32x32 48x48 scalable; do \
$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/status/$${FILE_SVG%.*}".{svg,png,jpg}; \
done; \
done
@$(RM) "${DESTDIR}${PREFIX}/bin/${PKGNAME}"
@$(RM) "${DESTDIR}${PREFIX}/share/applications/${PKGNAME}.desktop"
@$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.svg"
@$(RM) -rd "${DESTDIR}${PREFIX}/share/${PKGNAME}"
@if [ -z ${DESTDIR} ]; then \
[ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \
update-desktop-database --quiet &>/dev/null || true; \
[ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \
fi
@echo "Uninstall: OK"
install: check uninstall
@echo "Install ..."
@for FILE_PO in $(wildcard *.po); do \
LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \
install -dm755 "${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES"; \
FILE_MO=$${FILE_PO##*/}; FILE_MO="$${FILE_MO%_*.po}.mo"; \
PATH_FILE_MO="${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \
echo "$${FILE_PO}"; \
msgfmt "$${FILE_PO}" -v -f -o "$${PATH_FILE_MO}"; \
done
@for SIZE in 16 32 48; do \
install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps"; \
rsvg-convert -w $${SIZE} -h $${SIZE} -f svg --keep-image-data "com.ublinux.${PKGNAME}.svg" -o "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \
done
@install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg"
@install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}"
@install -dm755 "${DESTDIR}/etc/xdg"
@install -dm755 "${DESTDIR}${PREFIX}/share/applications"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop"
@install -dm755 "${DESTDIR}${PREFIX}/share/${PKGNAME}"/{ui,css,images}
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/ui/" "${PKGNAME}.glade"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/css/" "${PKGNAME}.css"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/ui/" "${PKGNAME}-banner.png"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.ubl-settings-quotas.checked.svg"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.ubl-settings-quotas.warning.svg"
@if [ -z ${DESTDIR} ]; then \
[ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \
update-desktop-database --quiet &>/dev/null || true; \
[ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \
fi
@echo "Install: OK"
clean:
@echo "Clean ..."
@$(RM) -rd ${CMAKE_BUILD_DIR}
@if [ -d ${CMAKE_BUILD_DIR} ]; then \
echo "Clean: error, compile directory exist ${CMAKE_BUILD_DIR}"; \
else \
echo "Clean: OK"; \
fi
up_ver:
@CURRENT=$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2); \
MAJOR=$$(cut -d. -f1 <<< $${CURRENT}); \
MINOR=$$(cut -d. -f2 <<< $${CURRENT}); \
VER="$${MAJOR}.$$(($${MINOR}+1))"; \
sed "s/VERSION *[[:digit:]]*.*/VERSION $${VER}/" -i ${FILE_VERSION}; \
echo "Updated version to VERSION.md: $${CURRENT} to $${VER}"
help:
@echo "The following are some of the valid targets for this Makefile:"; \
echo "... all (the default if no target is provided)"; \
echo "... init"; \
echo "... debug"; \
echo "... prepare"; \
echo "... compile"; \
echo "... install"; \
echo "... uninstall"; \
echo "... clean"; \
echo "... up_ver"

@ -1,2 +1,44 @@
# ubl-settings-quotas
# Настройки квот
[RU] Утилита для настройки квот
Utility for setting the date and time
![alt text](screenshot/screenshot.png)
# Build
In order to build ubl-settings-quotas you will need:
- CMake
- C compiler
- GTK+ 3 & dependencies
Once you have all the necessary dependencies, you can use:
```sh
$ make
```
# Installation
After a successful build, just use:
```sh
$ sudo make install clean
```
# Uninstallation
After a successful build, just use:
```sh
$ sudo make uninstall
```
# Usage
```sh
$ ubl-settings-quotas --help
GTK settings quotas for UBLinux
Usage: ubl-settings-quotas [OPTIONS...]
Options:
-h, --help Show this help
-V, --version Show package version
$ ubl-settings-quotas --version
ubl-settings-quotas version: x.xx
```

@ -0,0 +1 @@
VERSION 1.0

@ -0,0 +1,327 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="24"
height="24"
version="1.1"
viewBox="0 0 24 24"
id="svg25"
sodipodi:docname="checked.svg"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview27"
pagecolor="#ffffff"
bordercolor="#999999"
borderopacity="1"
inkscape:pageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
showgrid="false"
inkscape:zoom="14.8125"
inkscape:cx="-4.6919831"
inkscape:cy="9.9578059"
inkscape:window-width="1920"
inkscape:window-height="1027"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg25" />
<defs
id="defs19">
<style
id="current-color-scheme"
type="text/css">.ColorScheme-Text {
color:#31363b;
}
.ColorScheme-Background{
color:#eff0f1;
}
.ColorScheme-ViewText {
color:#31363b;
}
.ColorScheme-ViewBackground{
color:#fcfcfc;
}
.ColorScheme-ViewHover {
color:#3daee9;
}
.ColorScheme-ViewFocus{
color:#3daee9;
}
.ColorScheme-ButtonText {
color:#31363b;
}
.ColorScheme-ButtonBackground{
color:#eff0f1;
}
.ColorScheme-ButtonHover {
color:#3daee9;
}
.ColorScheme-ButtonFocus{
color:#3daee9;
}</style>
<style
type="text/css"
id="style3">.ColorScheme-Text {
color:#31363b;
}
.ColorScheme-Background{
color:#eff0f1;
}
.ColorScheme-ViewText {
color:#31363b;
}
.ColorScheme-ViewBackground{
color:#fcfcfc;
}
.ColorScheme-ViewHover {
color:#3daee9;
}
.ColorScheme-ViewFocus{
color:#3daee9;
}
.ColorScheme-ButtonText {
color:#31363b;
}
.ColorScheme-ButtonBackground{
color:#eff0f1;
}
.ColorScheme-ButtonHover {
color:#3daee9;
}
.ColorScheme-ButtonFocus{
color:#3daee9;
}</style>
<style
type="text/css"
id="style5">.ColorScheme-Text {
color:#31363b;
}
.ColorScheme-Background{
color:#eff0f1;
}
.ColorScheme-ViewText {
color:#31363b;
}
.ColorScheme-ViewBackground{
color:#fcfcfc;
}
.ColorScheme-ViewHover {
color:#3daee9;
}
.ColorScheme-ViewFocus{
color:#3daee9;
}
.ColorScheme-ButtonText {
color:#31363b;
}
.ColorScheme-ButtonBackground{
color:#eff0f1;
}
.ColorScheme-ButtonHover {
color:#3daee9;
}
.ColorScheme-ButtonFocus{
color:#3daee9;
}</style>
<style
type="text/css"
id="style7">.ColorScheme-Text {
color:#31363b;
}
.ColorScheme-Background{
color:#eff0f1;
}
.ColorScheme-ViewText {
color:#31363b;
}
.ColorScheme-ViewBackground{
color:#fcfcfc;
}
.ColorScheme-ViewHover {
color:#3daee9;
}
.ColorScheme-ViewFocus{
color:#3daee9;
}
.ColorScheme-ButtonText {
color:#31363b;
}
.ColorScheme-ButtonBackground{
color:#eff0f1;
}
.ColorScheme-ButtonHover {
color:#3daee9;
}
.ColorScheme-ButtonFocus{
color:#3daee9;
}</style>
<style
type="text/css"
id="style9">.ColorScheme-Text {
color:#31363b;
}
.ColorScheme-Background{
color:#eff0f1;
}
.ColorScheme-ViewText {
color:#31363b;
}
.ColorScheme-ViewBackground{
color:#fcfcfc;
}
.ColorScheme-ViewHover {
color:#3daee9;
}
.ColorScheme-ViewFocus{
color:#3daee9;
}
.ColorScheme-ButtonText {
color:#31363b;
}
.ColorScheme-ButtonBackground{
color:#eff0f1;
}
.ColorScheme-ButtonHover {
color:#3daee9;
}
.ColorScheme-ButtonFocus{
color:#3daee9;
}</style>
<style
type="text/css"
id="style11">.ColorScheme-Text {
color:#31363b;
}
.ColorScheme-Background{
color:#eff0f1;
}
.ColorScheme-ViewText {
color:#31363b;
}
.ColorScheme-ViewBackground{
color:#fcfcfc;
}
.ColorScheme-ViewHover {
color:#3daee9;
}
.ColorScheme-ViewFocus{
color:#3daee9;
}
.ColorScheme-ButtonText {
color:#31363b;
}
.ColorScheme-ButtonBackground{
color:#eff0f1;
}
.ColorScheme-ButtonHover {
color:#3daee9;
}
.ColorScheme-ButtonFocus{
color:#3daee9;
}</style>
<style
type="text/css"
id="style13">.ColorScheme-Text {
color:#31363b;
}
.ColorScheme-Background{
color:#eff0f1;
}
.ColorScheme-ViewText {
color:#31363b;
}
.ColorScheme-ViewBackground{
color:#fcfcfc;
}
.ColorScheme-ViewHover {
color:#3daee9;
}
.ColorScheme-ViewFocus{
color:#3daee9;
}
.ColorScheme-ButtonText {
color:#31363b;
}
.ColorScheme-ButtonBackground{
color:#eff0f1;
}
.ColorScheme-ButtonHover {
color:#3daee9;
}
.ColorScheme-ButtonFocus{
color:#3daee9;
}</style>
<style
type="text/css"
id="style15">.ColorScheme-Text {
color:#31363b;
}
.ColorScheme-Background{
color:#eff0f1;
}
.ColorScheme-ViewText {
color:#31363b;
}
.ColorScheme-ViewBackground{
color:#fcfcfc;
}
.ColorScheme-ViewHover {
color:#3daee9;
}
.ColorScheme-ViewFocus{
color:#3daee9;
}
.ColorScheme-ButtonText {
color:#31363b;
}
.ColorScheme-ButtonBackground{
color:#eff0f1;
}
.ColorScheme-ButtonHover {
color:#3daee9;
}
.ColorScheme-ButtonFocus{
color:#3daee9;
}</style>
<style
type="text/css"
id="style17">.ColorScheme-Text {
color:#31363b;
}
.ColorScheme-Background{
color:#eff0f1;
}
.ColorScheme-ViewText {
color:#31363b;
}
.ColorScheme-ViewBackground{
color:#fcfcfc;
}
.ColorScheme-ViewHover {
color:#3daee9;
}
.ColorScheme-ViewFocus{
color:#3daee9;
}
.ColorScheme-ButtonText {
color:#31363b;
}
.ColorScheme-ButtonBackground{
color:#eff0f1;
}
.ColorScheme-ButtonHover {
color:#3daee9;
}
.ColorScheme-ButtonFocus{
color:#3daee9;
}</style>
</defs>
<path
id="path21"
d="M 12 1 C 5.906 1 1 5.906 1 12 C 1 18.094 5.906 23 12 23 C 18.094 23 23 18.094 23 12 C 23 5.906 18.094 1 12 1 z M 15.480469 8.9042969 C 16.392469 8.8782969 16.860031 9.9850937 16.207031 10.621094 L 11 15.828125 L 8.09375 12.921875 C 7.11175 11.979875 8.5648125 10.525813 9.5078125 11.507812 L 11 13 L 14.792969 9.2070312 A 1 1 0 0 1 15.480469 8.9042969 z "
style="fill:#4d4d4d;fill-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 7.4 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 210 KiB

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 24 24"
id="svg2"
version="1.1"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)"
sodipodi:docname="warning.svg"
width="24"
height="24"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<metadata
id="metadata12">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs10" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1027"
id="namedview8"
showgrid="false"
inkscape:zoom="18.96875"
inkscape:cx="5.4827018"
inkscape:cy="9.3047776"
inkscape:current-layer="svg2"
inkscape:pagecheckerboard="0"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<path
id="path4136-2"
style="opacity:1;fill:#4d4d4d;fill-opacity:1"
d="M 11.292969 1.0234375 A 11 11.000002 86.311656 0 0 1.0234375 12.707031 A 11 11.000002 86.311656 0 0 12.707031 22.976562 A 11 11.000002 86.311656 0 0 22.976562 11.292969 A 11 11.000002 86.311656 0 0 11.292969 1.0234375 z M 11.996094 6 L 12.003906 6 C 12.556173 6 13 6.4439 13 6.9960938 L 13 14.003906 C 13 14.556325 12.556173 15 12.003906 15 L 11.996094 15 C 11.443827 15 11 14.556325 11 14.003906 L 11 6.9960938 C 11 6.4439 11.443827 6 11.996094 6 z M 12 17 C 12.554 17 13 17.446 13 18 C 13 18.554 12.554 19 12 19 C 11.446 19 11 18.554 11 18 C 11 17.446 11.446 17 12 17 z " />
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.7)
project(ubl-settings-quotas)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED gtkmm-3.0)
include_directories(${GTK_INCLUDE_DIRS})
link_directories(${GTK_LIBRARY_DIRS})
add_definitions(${GTK_CFLAGS_OTHER})
find_package(ICU REQUIRED COMPONENTS uc dt in io)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \
-O2 -pipe -fno-plt -fexceptions \
-Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
-fstack-clash-protection -fcf-protection -g")
set(SOURCE_FILES
util.h
util.cc
ubl-util-standard.h
ubl-util-standard.c
ubl-settings-quotas.h
ubl-settings-quotas.cc
main.cc)
set(LIBRARIES
${GTK_LIBRARIES}
pthread)
add_executable(ubl-settings-quotas ${SOURCE_FILES})
target_link_libraries(ubl-settings-quotas ${LIBRARIES} ${ICU_LIBRARIES})
install(TARGETS ubl-settings-quotas DESTINATION bin)

@ -0,0 +1,76 @@
#include "ubl-settings-quotas.h"
void pars_flag(int index_start, int argc, char* argv[]);
int main(int argc, char** argv) {
string str_argv= "";
string str_cmd_argv = "";
for (int i=1; i<argc; i++){
str_cmd_argv+= to_string(*argv[i]) + " ";
}
if (argc > 1){
str_argv = argv[1];
}
bindtextdomain(app_name.c_str(), "/usr/share/locale/");
bind_textdomain_codeset(app_name.c_str(), "UTF-8");
textdomain(app_name.c_str());
if (str_argv.find("--socket-id") != std::string::npos) {
auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example.plug");
auto builder = Gtk::Builder::create_from_file(path_glade);
Glib::init();
setlocale(LC_ALL, "");
Glib::OptionContext context;
CmdArgParser parser{
"Socket ID",
"Command line argument for socket ID communication.",
"No help available, sorry"
};
context.set_main_group(parser);
context.parse(argc, argv);
::Window socketID = parser.GetSocketID();
// Handle plug:
SettingsPlug plug{socketID, builder};
plug.show();
app->run(plug);
return 0;
}
else if (str_argv.find("-") != std::string::npos || argc == 1) {
int len_argv = 1;
auto app = Gtk::Application::create(len_argv, argv, "org.gtkmm.example.plug");
auto builder = Gtk::Builder::create_from_file(path_glade);
pars_flag(1, argc, argv);
MainWindow* wnd = nullptr;
builder->get_widget_derived("MainWindow", wnd);
auto r = app->run(*wnd);
delete wnd;
return r;
}
}
void pars_flag(int index_start, int argc, char* argv[]) {
string str_argv = "";
for (int i = index_start; i<argc; i++){
str_argv = argv[i];
if (str_argv == "--help" || str_argv == "-h"){
help();
exit(1);
}
else if (str_argv == "--version" || str_argv == "-v"){
string version = string(gettext("ubl-settings-quotas version: ")) + version_application + "\n";
cout << version.c_str();
exit(1);
}
else{
if (index_start == 1){
cout << (gettext("Argument not recognized\n")) << endl;
}
}
}
}

@ -0,0 +1,224 @@
#include "ubl-settings-quotas.h"
using namespace std;
const string path_app = "/usr/bin/";
const string path_glade = "/usr/share/ubl-settings-quotas/ui/ubl-settings-quotas.glade";
const string app_name = "ubl-settings-quotas";
const string path_locale = "/usr/share/locale/";
const string path_css = "/usr/share/ubl-settings-quotas/css/ubl-settings-quotas.css";
const string path_img_head_background = "/usr/share/ubl-settings-quotas/ui/ubl-settings-quotas-banner.png";
int socket_ext_id_I = 0;
int socket_trd_id_I = 0;
string version_application = "1.0";
CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help)
: Glib::OptionGroup{p_name, p_description, p_help} {
Glib::OptionEntry socketIDArg;
socketIDArg.set_long_name("socket-id");
socketIDArg.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
socketIDArg.set_description("Settings manager socket");
Glib::OptionEntry socketExtId;
socketExtId.set_long_name("socket-ext-id");
socketExtId.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
socketExtId.set_description("Settings manager secondary socket");
Glib::OptionEntry socketTrdId;
socketTrdId.set_long_name("socket-trd-id");
socketTrdId.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
socketTrdId.set_description("Settings manager secondary socket");
add_entry(socketIDArg, m_socketID);
add_entry(socketExtId, socket_ext_id_I);
add_entry(socketTrdId, socket_trd_id_I);
}
::Window CmdArgParser::GetSocketID() const{
return m_socketID;
}
MainWindow::MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder)
: Gtk::ApplicationWindow(obj), builder{builder} {
this->builder = builder;
this->settings();
}
MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
this->builder = builder;
this->settings();
}
void MainWindow::settings() {
this->get_builder();
this->lacalization();
this->add_CSS();
btnBoxAboutDialog->set_visible(false);
Gtk::Widget *boxWidget;
builder->get_widget("boxColor", boxWidget);
HeadOverlay->add_overlay(*boxWidget);
ubl_make_plugs(boxSave, boxButton, socket_ext_id_I, socket_trd_id_I);
if (geteuid() == 0) {
}
else {
boxFuncs->set_sensitive(false);
btnSave->set_sensitive(false);
btnLoad->set_sensitive(false);
imgInfo->set_from_icon_name("com.ublinux.ubl-settings-datetime.warning", Gtk::ICON_SIZE_MENU);
info_status_app("boxInfoMessError");
lblWarning->set_text(gettext("The program must be run as root"));
}
}
void MainWindow::lacalization() {
time_t now = time(0);
tm *ltm = localtime(&now);
unsigned int year = 1900+ ltm->tm_year;
string str_authors = string(gettext("Copyright © UBSoft LLC, 2022 - ")) + to_string(year);
aboutWindows->set_copyright(str_authors);
aboutWindows->set_comments(gettext("Date and Time"));
aboutWindows->set_website(gettext("https://wiki.ublinux.com"));
aboutWindows->set_version(gettext(version_application.c_str()));
aboutWindows->set_website_label(gettext("Project Home Page"));
generalTabLabel->set_text(gettext("General settings"));
GroupsTabLabel->set_text(gettext("Groups"));
UsersTabLabel->set_text(gettext("Users"));
generalDeviceLabel->set_text(gettext("Device:"));
generalFileSystemLabel->set_text(gettext("File system:"));
generalGroupsFrameLabel->set_text(gettext("quotas for groups"));
generalGroupsEnableCheck->set_label(gettext("Enable"));
generalUsersEnableCheck->set_label(gettext("Enable"));
generalUsersFrameLabel->set_label(gettext("quotas for users"));
generalGroupsSizeLabel->set_text(gettext("Excess size delay period"));
generalGroupsFilesLabel->set_text(gettext("Excess files delay period"));
generalUsersSizeLabel->set_text(gettext("Excess size delay period"));
generalUsersFilesLabel->set_text(gettext("Excess files delay period"));
generalGroupsSizeWeeksLabel->set_text(gettext("weeks"));
generalGroupsFilesWeeksLabel->set_text(gettext("weeks"));
generalUsersSizeWeeksLabel->set_text(gettext("weeks"));
generalUsersFilesWeeksLabel->set_text(gettext("weeks"));
generalGroupsSizeDaysLabel->set_text(gettext("days"));
generalGroupsFilesDaysLabel->set_text(gettext("days"));
generalUsersSizeDaysLabel->set_text(gettext("days"));
generalUsersFilesDaysLabel->set_text(gettext("days"));
generalGroupsSizeHoursLabel->set_text(gettext("hours"));
generalGroupsFilesHoursLabel->set_text(gettext("hours"));
generalUsersSizeHoursLabel->set_text(gettext("hours"));
generalUsersFilesHoursLabel->set_text(gettext("hours"));
generalGroupsSizeMinutesLabel->set_text(gettext("minutes"));
generalGroupsFilesMinutesLabel->set_text(gettext("minutes"));
generalUsersSizeMinutesLabel->set_text(gettext("minutes"));
generalUsersFilesMinutesLabel->set_text(gettext("minutes"));
lblLoad->set_text(gettext("Load"));
lblSave->set_text(gettext("Save"));
}
void MainWindow::add_CSS() {
Glib::RefPtr<Gtk::CssProvider> cssProvider = Gtk::CssProvider::create();
cssProvider->load_from_path(path_css);
Glib::RefPtr<Gtk::StyleContext> styleContext = Gtk::StyleContext::create();
Glib::RefPtr<Gdk::Screen> screen = Gdk::Screen::get_default();//get default screen
styleContext->add_provider_for_screen(screen, cssProvider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);//add provider for screen in all application
HeadBackgroundImage->set(path_img_head_background);
//Glib::RefPtr<Gtk::StyleContext> headerTopic_css = headerTopic->get_style_context();
Glib::RefPtr<Gtk::StyleContext> boxButton_css = boxButton->get_style_context();
Glib::RefPtr<Gtk::StyleContext> boxSave_css = boxSave->get_style_context();
Glib::RefPtr<Gtk::StyleContext> headerBar_css = headerBar->get_style_context();
if (socket_trd_id_I == 0 && socket_ext_id_I == 0){
boxButton_css->add_class("bkim_no_plug");
boxSave_css->add_class("bkim_no_plug");
}
//headerTopic_css->add_class("textHead");
}
void MainWindow::get_builder() {
builder->set_translation_domain(path_app);
builder->get_widget("headerTopic", headerTopic);
builder->get_widget("boxButton", boxButton);
builder->get_widget("boxSave", boxSave);
builder->get_widget("aboutWindows", aboutWindows);
builder->get_widget("HeadOverlay", HeadOverlay);
builder->get_widget("headerBar", headerBar);
builder->get_widget("boxFuncs", boxFuncs);
builder->get_widget("btnLoad", btnLoad);
builder->get_widget("btnSave", btnSave);
builder->get_widget("btnBoxAboutDialog", btnBoxAboutDialog);
builder->get_widget("HeadBackgroundImage", HeadBackgroundImage);
builder->get_widget("imgInfo", imgInfo);
builder->get_widget("lblWarning", lblWarning);
builder->get_widget("boxInfoError", boxInfoError);
builder->get_widget("imgInfo", imgInfo);
builder->get_widget("generalTabLabel", generalTabLabel);
builder->get_widget("GroupsTabLabel", GroupsTabLabel);
builder->get_widget("UsersTabLabel", UsersTabLabel);
builder->get_widget("generalDeviceLabel", generalDeviceLabel);
builder->get_widget("generalGroupsFrameLabel", generalGroupsFrameLabel);
builder->get_widget("generalGroupsSizeLabel", generalGroupsSizeLabel);
builder->get_widget("generalGroupsFilesLabel", generalGroupsFilesLabel);
builder->get_widget("generalUsersFrameLabel", generalUsersFrameLabel);
builder->get_widget("generalUsersSizeLabel", generalUsersSizeLabel);
builder->get_widget("generalUsersFilesLabel", generalUsersFilesLabel);
builder->get_widget("generalGroupsSizeWeeksLabel", generalGroupsSizeWeeksLabel);
builder->get_widget("generalGroupsFilesWeeksLabel", generalGroupsFilesWeeksLabel);
builder->get_widget("generalUsersSizeWeeksLabel", generalUsersSizeWeeksLabel);
builder->get_widget("generalUsersFilesWeeksLabel", generalUsersFilesWeeksLabel);
builder->get_widget("generalGroupsSizeDaysLabel", generalGroupsSizeDaysLabel);
builder->get_widget("generalGroupsFilesDaysLabel", generalGroupsFilesDaysLabel);
builder->get_widget("generalUsersSizeDaysLabel", generalUsersSizeDaysLabel);
builder->get_widget("generalUsersFilesDaysLabel", generalUsersFilesDaysLabel);
builder->get_widget("generalGroupsSizeHoursLabel", generalGroupsSizeHoursLabel);
builder->get_widget("generalGroupsFilesHoursLabel", generalGroupsFilesHoursLabel);
builder->get_widget("generalUsersSizeHoursLabel", generalUsersSizeHoursLabel);
builder->get_widget("generalUsersFilesHoursLabel", generalUsersFilesHoursLabel);
builder->get_widget("generalGroupsSizeMinutesLabel", generalGroupsSizeMinutesLabel);
builder->get_widget("generalGroupsFilesMinutesLabel", generalGroupsFilesMinutesLabel);
builder->get_widget("generalUsersSizeMinutesLabel", generalUsersSizeMinutesLabel);
builder->get_widget("generalUsersFilesMinutesLabel", generalUsersFilesMinutesLabel);
builder->get_widget("generalFileSystemLabel", generalFileSystemLabel);
builder->get_widget("generalGroupsEnableCheck", generalGroupsEnableCheck);
builder->get_widget("generalUsersEnableCheck", generalUsersEnableCheck);
builder->get_widget("lblLoad", lblLoad);
builder->get_widget("lblSave", lblSave);
builder->get_widget("btnSettings", btnSettings);
}
void MainWindow::event() {
btnLoadGlob->signal_activate().connect([&]() {});
btnLoadLocal->signal_activate().connect([&]() {});
btnSynopsis->signal_activate().connect([&]() {});
btnAbout->signal_activate().connect([&]() {});
btnSaveLocalGlob->signal_activate().connect([&]() {});
btnSaveGlob->signal_activate().connect([&]() {});
btnSaveLocal->signal_activate().connect([&]() {});
}
void MainWindow::info_status_app(string stule) {
Glib::RefPtr<Gtk::StyleContext> boxInfo = boxInfoError->get_style_context();
boxInfo->remove_class("boxInfoMessOK");
boxInfo->remove_class("boxInfoMessError");
boxInfo->add_class(stule);
}
SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr<Gtk::Builder> builder)
:Gtk::Plug{p_socketID} {
MainWindow* wnd = nullptr;
builder->get_widget_derived("window", wnd);
builder->get_widget("plugBox", plugBox);
plugBox->get_parent()->remove(*plugBox);
add(*plugBox);
show_all_children();
}
void help() {
string version = string(gettext("ubl-settings-quotas version: ")) + version_application + "\n";
cout << version.c_str();
string help;
help = "GTK settings quotas. for UBLinux\n\n"
"Usage: ubl-settings-quotas [OPTIONS...]\n"
"Options:\n"
" -h, --help Show this help\n"
" -V, --version Show package version\n";
cout << gettext(help.c_str());
}

@ -0,0 +1,117 @@
#ifndef UBL_SETTINGS_QUOTAS_H
#define UBL_SETTINGS_QUOTAS_H
#include <gtkmm/window.h>
#include <glibmm/i18n.h>
#include <gtkmm/plug.h>
#include <gtkmm/stock.h>
#include <gtkmm.h>
#include "ubl-util-standard.c"
#include "util.h"
using namespace std;
extern const string path_app;
extern const string path_glade;
extern const string app_name;
extern const string path_locale;
extern const string path_css;
extern const string path_img_head_background;
extern int socket_ext_id_I;
extern int socket_trd_id_I;
extern string version_application;
class CmdArgParser : public Glib::OptionGroup {
public:
CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help);
::Window GetSocketID() const;
private:
int m_socketID = 0;
};
class MainWindow : public Gtk::ApplicationWindow {
public:
Glib::RefPtr<Gtk::Builder> builder;
template<typename Type>
struct Result{
Type response;
int error;
};
Gtk::Label *headerTopic;
Gtk::AboutDialog *aboutWindows;
Gtk::Overlay *HeadOverlay;
Gtk::HeaderBar *headerBar;
Gtk::Box *boxSave;
Gtk::Box *boxButton;
Gtk::Box *boxFuncs;
Gtk::MenuButton *btnSave;
Gtk::MenuButton *btnLoad;
Gtk::MenuButton *btnSettings;
Gtk::ButtonBox *btnBoxAboutDialog;
Gtk::Image *HeadBackgroundImage;
Gtk::Image *imgInfo;
Gtk::Box *boxInfoError;
Gtk::Label *lblWarning;
Gtk::Label *generalTabLabel;
Gtk::Label *UsersTabLabel;
Gtk::Label *GroupsTabLabel;
Gtk::Label *generalDeviceLabel;
Gtk::Label *generalGroupsFrameLabel;
Gtk::Label *generalGroupsSizeLabel;
Gtk::Label *generalGroupsFilesLabel;
Gtk::Label *generalUsersFrameLabel;
Gtk::Label *generalUsersSizeLabel;
Gtk::Label *generalUsersFilesLabel;
Gtk::Label *generalGroupsSizeWeeksLabel;
Gtk::Label *generalGroupsFilesWeeksLabel;
Gtk::Label *generalUsersSizeWeeksLabel;
Gtk::Label *generalUsersFilesWeeksLabel;
Gtk::Label *generalGroupsSizeDaysLabel;
Gtk::Label *generalGroupsFilesDaysLabel;
Gtk::Label *generalUsersSizeDaysLabel;
Gtk::Label *generalUsersFilesDaysLabel;
Gtk::Label *generalGroupsSizeHoursLabel;
Gtk::Label *generalGroupsFilesHoursLabel;
Gtk::Label *generalUsersSizeHoursLabel;
Gtk::Label *generalUsersFilesHoursLabel;
Gtk::Label *generalGroupsSizeMinutesLabel;
Gtk::Label *generalGroupsFilesMinutesLabel;
Gtk::Label *generalUsersSizeMinutesLabel;
Gtk::Label *generalUsersFilesMinutesLabel;
Gtk::Label *generalFileSystemLabel;
Gtk::Label *lblLoad;
Gtk::Label *lblSave;
Gtk::CheckButton *generalGroupsEnableCheck;
Gtk::CheckButton *generalUsersEnableCheck;
Gtk::MenuItem *btnLoadGlob;
Gtk::MenuItem *btnLoadLocal;
Gtk::MenuItem *btnSynopsis;
Gtk::MenuItem *btnAbout;
Gtk::MenuItem *btnSaveLocalGlob;
Gtk::MenuItem *btnSaveGlob;
Gtk::MenuItem *btnSaveLocal;
public:
MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder);
MainWindow(Glib::RefPtr<Gtk::Builder> const& builder);
void settings();
void lacalization();
void add_CSS();
void get_builder();
void event();
void info_status_app(string stule);
};
class SettingsPlug : public Gtk::Plug{
public:
Gtk::Window *window;
SettingsPlug(::Window p_socketID, Glib::RefPtr<Gtk::Builder> builder);
private:
Gtk::Widget *plugBox;
Gtk::Widget *parent;
};
void help();
#endif

@ -0,0 +1,91 @@
#include "ubl-util-standard.h"
#ifndef __cplusplus
#ifndef UBL_GET_STANDARD_UI
#define UBL_GET_STANDARD_UI
inline returnstruct *ubl_make_plugs(GtkWidget *LeftWidget, GtkWidget *RightWidget, int left_plug_id, int right_plug_id){
returnstruct *ret=(returnstruct*)malloc(sizeof(returnstruct*));
if (left_plug_id>0&&LeftWidget){
GtkWidget *plug=gtk_plug_new(left_plug_id);
GtkWidget *toplug=LeftWidget;
if (gtk_widget_get_parent(GTK_WIDGET(toplug))){
g_object_ref(G_OBJECT(toplug));
GtkWidget *parent=gtk_widget_get_parent(toplug);
gtk_container_remove(GTK_CONTAINER(parent),toplug);
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
} else
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
gtk_widget_show(GTK_WIDGET(plug));
ret->plugLeft=plug;
}
if (right_plug_id>0&&RightWidget){
GtkWidget *plug=gtk_plug_new(right_plug_id);
GtkWidget *toplug=RightWidget;
if (gtk_widget_get_parent(GTK_WIDGET(toplug))){
g_object_ref(G_OBJECT(toplug));
GtkWidget *parent=gtk_widget_get_parent(toplug);
gtk_container_remove(GTK_CONTAINER(parent),toplug);
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
} else
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
gtk_widget_show(GTK_WIDGET(plug));
ret->plugRight=plug;
}
return ret;
}
#endif
#else
inline void ubl_make_plugs(Gtk::Widget *LeftWidget, Gtk::Widget *RightWidget, int left_plug_id, int right_plug_id){
if (left_plug_id>0&&LeftWidget){
GtkWidget *plug=gtk_plug_new(left_plug_id);
GtkWidget *toplug=GTK_WIDGET(LeftWidget->gobj());
{GdkScreen *screen = gtk_widget_get_screen(plug);
gtk_widget_set_app_paintable(plug,TRUE);
GdkVisual *colormap = gdk_screen_get_rgba_visual(screen);
gtk_widget_set_visual(plug, colormap);}
{GdkScreen *screen = gtk_widget_get_screen(toplug);
gtk_widget_set_app_paintable(toplug,TRUE);
GdkVisual *colormap = gdk_screen_get_rgba_visual(screen);
gtk_widget_set_visual(toplug, colormap);}
if (gtk_widget_get_parent(GTK_WIDGET(toplug))){
g_object_ref(G_OBJECT(toplug));
GtkWidget *parent=gtk_widget_get_parent(toplug);
gtk_container_remove(GTK_CONTAINER(parent),toplug);
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
} else
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
gtk_widget_show(GTK_WIDGET(plug));
gtk_style_context_add_class(gtk_widget_get_style_context(plug),"bkim");
gtk_style_context_add_class(gtk_widget_get_style_context(toplug),"bkim");
gtk_style_context_add_class(gtk_widget_get_style_context(plug),"primary-toolbar");
}
if (right_plug_id>0&&RightWidget){
GtkWidget *plug=gtk_plug_new(right_plug_id);
GtkWidget *toplug=GTK_WIDGET(RightWidget->gobj());
{GdkScreen *screen = gtk_widget_get_screen(plug);
gtk_widget_set_app_paintable(plug,TRUE);
GdkVisual *colormap = gdk_screen_get_rgba_visual(screen);
gtk_widget_set_visual(plug, colormap);}
{GdkScreen *screen = gtk_widget_get_screen(toplug);
gtk_widget_set_app_paintable(toplug,TRUE);
GdkVisual *colormap = gdk_screen_get_rgba_visual(screen);
gtk_widget_set_visual(toplug, colormap);}
if (gtk_widget_get_parent(GTK_WIDGET(toplug))){
g_object_ref(G_OBJECT(toplug));
GtkWidget *parent=gtk_widget_get_parent(toplug);
gtk_container_remove(GTK_CONTAINER(parent),toplug);
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
} else
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
gtk_widget_show(GTK_WIDGET(plug));
gtk_style_context_add_class(gtk_widget_get_style_context(plug),"bkim");
gtk_style_context_add_class(gtk_widget_get_style_context(toplug),"bkim");
gtk_style_context_add_class(gtk_widget_get_style_context(plug),"primary-toolbar");
}
}
#endif

@ -0,0 +1,20 @@
#ifndef __cplusplus
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
typedef struct {
GtkWidget *plugLeft;
GtkWidget *plugRight;
} returnstruct;
static returnstruct *ubl_make_plugs(GtkWidget *LeftWidget, GtkWidget *RightWidget, int left_plug_id, int right_plug_id);
#else
#include <gtkmm.h>
#include <gtkmm/stock.h>
#include <gtkmm/window.h>
#include <gtkmm/plug.h>
static void ubl_make_plugs(Gtk::Widget *LeftWidget, Gtk::Widget *RightWidget, int left_plug_id, int right_plug_id);
#endif

@ -0,0 +1,195 @@
#include "util.h"
array<vector<string>, 5> read_csv(const string& filename) {
array<vector<string>, 5> array_vectors;
vector<string> vec_option;
vector<string> vec_opcision;
ifstream file(filename);
string line;
char delimiter = ',';
getline(file, line);
while (getline(file, line)) {
stringstream stream(line);
string option;
string opcision;
getline(stream, option, delimiter);
string line_local = stream.str();
if (line_local.find("\"") != string::npos) {
string str_delimiter = "\"";
vector<int> point = find_all(line_local, str_delimiter);
size_t len = point.size();
if (len >= 2) {
int index_start = point[len-2];
int index_end = point[len-1];
opcision = line_local.substr(index_start, index_end);
index_end = opcision.find("\"");
if (opcision.find("\"") != string::npos) {
opcision.replace(index_end, opcision.length(), "");
}
}
else {
opcision = "error";
}
}
else{
getline(stream, opcision, delimiter);
}
vec_option.push_back(option);
vec_opcision.push_back(opcision);
}
array_vectors[0] = vec_option;
array_vectors[1] = vec_opcision;
return array_vectors;
}
string call(string cmd) {
FILE *fp;
int status;
char path[PATH_MAX] = {0};
fp = popen(cmd.c_str(), "r");
if (fp == NULL) {
exit(1);
}
while (fgets(path, PATH_MAX, fp) != NULL) {
break;
}
status = pclose(fp);
if (status == -1) {
exit(1);
}
return path;
}
vector<int> find_all(string &str_ntp, string substr) {
size_t index = 0;
vector<int> sub_index;
while ((index = str_ntp.find(substr, index)) != std::string::npos) {
index += substr.length();
sub_index.push_back(index);
}
return sub_index;
}
void str_remove(std::string& source, std::string to_remove) {
string::size_type n = to_remove.length();
for (string::size_type i = source.find(to_remove);
i != string::npos;
i = source.find(to_remove))
source.erase(i, n);
}
void str_replace_all(std::string& str_base, string str_find, string sReplacement)
{
size_t pos = 0, fpos;
while ((fpos = str_base.find(str_find, pos)) != std::string::npos)
{
str_base.replace(fpos, str_find.size(), sReplacement);
pos = fpos + sReplacement.size();
}
}
std::vector<std::string> split(std::string text, char delim) {
std::string line;
std::vector<std::string> vec;
std::stringstream ss(text);
while(std::getline(ss, line, delim)) {
vec.push_back(line);
}
return vec;
}
unsigned short read_uid_min_max(string filename, string search) {
std::string line;
int uid = 0;
string remove_tab = "\t";
string remove_space = " ";
std::ifstream in(filename); // окрываем файл для чтения
if (in.is_open()){
while (getline(in, line)){
try{
if (line.find(search) != string::npos && (line.find("SYS_"+search) == string::npos)) {
str_remove(line, search);
str_remove(line, remove_space);
str_remove(line, remove_tab);
uid = atoi(line.c_str());
}
}
catch (int x) {
if (search == "UID_MIN"){
uid = 1000;
}
else{
uid = 65534;
}
}
}
}
else{
if (search == "UID_MIN") {
uid = 1000;
}
else{
uid = 65534;
}
}
in.close();
return uid;
}
vector <string> pars_users() {
vector <string> vec_users;
unsigned short uid_min = read_uid_min_max("/etc/login.defs", "UID_MIN");
unsigned short uid_max =read_uid_min_max("/etc/login.defs", "UID_MAX");
while (true) {
errno = 0;
passwd* entry = getpwent();
if (!entry) {
if (errno) {
break;
}
break;
}
if ((entry->pw_uid >= uid_min && entry->pw_uid < uid_max) || entry->pw_uid == 0) {
vec_users.push_back(string(entry->pw_name));
}
}
endpwent();
return vec_users;
}
string read_passwd(string username) {
string passwd = "";
std::string line;
std::ifstream in("/etc/shadow");
if (in.is_open()) {
while (getline(in, line)) {
if (line.find(username) != string::npos) {
size_t index_start = line.find(":");
if (index_start != string::npos) {
size_t index_end = line.find(":", index_start + 1);
passwd = line.substr(index_start+1, index_end - index_start-1);
break;
}
}
}
}
in.close();
return passwd;
}
int synopsis_show(string str_link) {
// gettext("https://wiki.ublinux.com/ru/Программное_обеспечениерограммы_и_утилиты/Все/")
string cmd = "xdg-open " + str_link;
if (geteuid() == 0) {
string response_user = getlogin();
cmd = "su -l " + response_user + " -c \" DISPLAY=$DISPLAY " + cmd + " \"";
}
return system(cmd.c_str());
}

@ -0,0 +1,41 @@
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <linux/limits.h>
#include <sys/types.h>
#include <pwd.h>
#include <unistd.h>
#include <sys/types.h>
#include <iostream>
#include <map>
#include <string>
#include <array>
#include <vector>
#include <fstream>
#include <filesystem>
#include <stdio.h>
#include <map>
#include <pwd.h>
using namespace std;
struct Passwd {
string user;
int uid;
};
std::array<std::vector<std::string>, 5> read_csv(const std::string& filename);
std::string call(std::string cmd);
vector<int> find_all(string &str_ntp, string substr);
void str_remove(std::string& source, std::string to_remove);
void str_replace_all(string &str_base, string str_find, string str_replace);
std::vector<std::string> split(std::string text, char delim);
unsigned short read_uid_min_max(string filename, string search);
vector <string> pars_users();
string read_passwd(string username);
int synopsis_show(string str_link);

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

@ -0,0 +1,149 @@
.textHead{
text-shadow: 2px 2px @theme_bg_color;
color: @theme_text_color;
}
.boxInfoMessError{
background-color: #ea9999;
}
.boxInfoMessOK{
background-color: #f3f0ac;
}
.bannerbackground {
background-color: #404040;
}
.textHead{
text-shadow: 1px 1px #ffffff;
}
.view_app {
background-color: @theme_bg_color;
}
.view_app.view.cell:selected {
background-color:@theme_selected_bg_color;
color:@theme_selected_text_color;
transition: 10ms ease-out;
border-radius: 3px;
}
#GnomeIcon{
border-style:solid;
border-bottom-width: 1px;
border-image: linear-gradient(90deg, alpha(@theme_text_color,0.4) 55%, alpha(@theme_bg_color, 0) 100%);
border-image-slice: 1;
}
#SepIcon{
background-color: alpha(@theme_text_color, 0.6);
}
#iconlabel {
font-size:14px;
font-weight: bold;
}
.roundborder * {
border-width:0px;
border-radius:5px;
}
.noborder {
border: none;
}
.menu:hover {
border-color:alpha(@theme_text_color, 0.01);
}
.menu {
border-color:alpha(@theme_text_color, 0.01);
}
.menu:hover >* {
border-color:alpha(@theme_text_color, 0.01);
}
.menuitembottom{
margin-top:0px;
margin-bottom:3px;
}
.menuitemmiddle{
margin-top:0px;
margin-bottom:0px;
}
.menuitemtop{
margin-bottom:0px;
}
.menuitemtop *{
margin:2px 2px 0 2px;
padding: 5px 10px 3px 5px;
}
.menuitemmiddle *{
margin:0 2px 0 2px;
padding: 3px 10px 3px 5px;
}
.menuitembottom *{
margin:0 2px 2px 2px;
padding: 3px 10px 5px 5px;
}
.menuitemtop:hover {
background:@theme_bg_color;
border-color:inherit;
border-left-width:inherit;
border-right-width:inherit;
}
.menuitemmiddle:hover {
background:@theme_bg_color;
border-color:inherit;
border-left-width:inherit;
border-right-width:inherit;
}
.menuitembottom:hover {
background:@theme_bg_color;
border-color:inherit;
border-left-width:inherit;
border-right-width:inherit;
}
.menuitemtop:hover* {
margin:2px 2px 0 2px;
padding: 5px 10px 3px 5px;
background:@theme_selected_bg_color;
border-radius:2px;
}
.menuitemmiddle:hover* {
margin:0 2px 0 2px;
padding: 3px 10px 3px 5px;
background:@theme_selected_bg_color;
border-radius:2px;
}
.menuitembottom:hover* {
margin:0 2px 2px 2px;
padding: 3px 10px 5px 5px;
background:@theme_selected_bg_color;
border-radius:2px;
}
.workingbg, #workingbg {
background-color:@theme_base_color;
}
.workingbg.view.cell:selected {
background-color:@theme_selected_bg_color;
}
.workingbg.view.cell:hover {
background-color:darker(@theme_selected_bg_color);
color:@theme_selected_text_color;
border-radius:3px;
}
.bkim {
transition: 200ms ease-out;
background-image: none;
}
.noborder{
border:none;
}
.bkim{
opacity:0.99;
border:none;
}
.bkim_no_plug{
background-color: transparent;
opacity:0.99;
}

@ -0,0 +1,15 @@
[Desktop Entry]
Encoding=UTF-8
Name=ubl-settings-quotas
Name[ru]=Настройки квот
GenericName=ubl-settings-quotas
GenericName[ru]=Настройки квот
Comment=ubl-settings-quotas
Comment[ru]=Приложение для управления настройками квот
Type=Application
Exec=ubl-settings-quotas
Icon=com.ublinux.ubl-settings-quotas
Terminal=false
X-XfcePluggable=true
X-UBLPluggable=true
Categories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save