From 3c0c3f0bd42b6b41e0d912f1f02e2e436e59741a Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 28 May 2024 18:06:14 +0600 Subject: [PATCH] WIP key creation window --- Makefile | 33 +-- crypt-key.csv | 7 + gresource.xml | 1 + source/CMakeLists.txt | 1 + source/ubl-settings-repomanager.c | 62 ++++- source/ubl-settings-repomanager.h | 25 +- source/ubl-strings.h | 2 + ubl-settings-repomanager-key.glade | 403 +++++++++++++++++++++++++++++ 8 files changed, 514 insertions(+), 20 deletions(-) create mode 100644 crypt-key.csv create mode 100644 ubl-settings-repomanager-key.glade diff --git a/Makefile b/Makefile index 84477f0..54fea27 100644 --- a/Makefile +++ b/Makefile @@ -112,29 +112,30 @@ install: check uninstall 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"; \ + install -dm755 "${DESTDIR}/usr/share/icons/hicolor/$${SIZE}x$${SIZE}/apps"; \ + rsvg-convert -w $${SIZE} -h $${SIZE} -f svg --keep-image-data "com.ublinux.${PKGNAME}.svg" -o "${DESTDIR}/usr/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \ done - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.document-symbolic.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.document-green-symbolic.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.document-red-symbolic.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.document-sign-symbolic.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.folder-symbolic.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.folder-green-symbolic.svg" - @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.folder-red-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.document-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.document-green-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.document-red-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.document-sign-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.folder-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.folder-green-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.folder-red-symbolic.svg" + @install -Dm755 -t "${DESTDIR}/usr/share/${PKGNAME}/csv/" "crypt-key.csv" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop" @install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}" @install -Dm644 "com.ublinux.${PKGNAME}.policy" "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy" @sed -e '\|annotate key=|s|/usr/bin|${PREFIX}/bin|' -e '/action id=/s/\.run/${PKGIDENT}\.run/' -i ${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy @if [ -z ${DESTDIR} ]; then \ - [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ + [ -d "${DESTDIR}/usr/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}/usr/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; \ + [ -d "${DESTDIR}/usr/share/applications" ] && touch "${DESTDIR}/usr/share/applications" &>/dev/null || true; \ fi @echo "Install: OK" diff --git a/crypt-key.csv b/crypt-key.csv new file mode 100644 index 0000000..d95b0a8 --- /dev/null +++ b/crypt-key.csv @@ -0,0 +1,7 @@ +KEY_NAME;KEY_DESCRIPTION +RSA;RSA/RSA +DSA ElGamal;DSA/ELG +DSA (sign only);DSA +RSA (sign only);RSA +GOST R 34.10-2012;GOST3410-2012 +GOST R 34.10-2001;GOST3410-2001 \ No newline at end of file diff --git a/gresource.xml b/gresource.xml index eb85a99..2434328 100644 --- a/gresource.xml +++ b/gresource.xml @@ -6,6 +6,7 @@ ubl-settings-repomanager-configuration.glade ubl-settings-repomanager-repo-block.glade ubl-settings-repomanager-filechooser.glade + ubl-settings-repomanager-key.glade ubl-settings-repomanager.css diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 1fe07f1..9ee5702 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -39,6 +39,7 @@ set(DEPENDFILES ../ubl-settings-repomanager-add.glade ../ubl-settings-repomanager-configuration.glade ../ubl-settings-repomanager-filechooser.glade + ../ubl-settings-repomanager-key.glade ../ubl-settings-repomanager-repo-block.glade ../gresource.xml ../ubl-settings-repomanager-banner.png diff --git a/source/ubl-settings-repomanager.c b/source/ubl-settings-repomanager.c index 170c2d5..eb824d2 100644 --- a/source/ubl-settings-repomanager.c +++ b/source/ubl-settings-repomanager.c @@ -93,7 +93,7 @@ void yon_storage_config_update(storage_config_window *window){ file_chooser_window *yon_file_chooser_window_new(){ file_chooser_window *window = malloc(sizeof(file_chooser_window)); - GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_filechooser_config); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_filechooser); window->Window = yon_gtk_builder_get_widget(builder,"Window"); window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); window->ChooseButton = yon_gtk_builder_get_widget(builder,"ChooseButton"); @@ -1126,6 +1126,49 @@ void on_ubl_settings_update_launch(){ yon_launch_app_with_arguments("ubl-settings-update",NULL); } +void on_calendar_open(GtkWidget *self,key_creation_window *window){ + yon_calendar_popover_open(GTK_ENTRY(window->ExpireEntry),self); +} + +key_creation_window *yon_key_creation_window_new(){ + key_creation_window *window = malloc(sizeof(key_creation_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_key); + window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + window->HeadLabel = yon_gtk_builder_get_widget(builder,"HeadLabel"); + window->NameEntry = yon_gtk_builder_get_widget(builder,"NameEntry"); + window->EmailEntry = yon_gtk_builder_get_widget(builder,"EmailEntry"); + window->CommentsEntry = yon_gtk_builder_get_widget(builder,"CommentsEntry"); + window->EncryptionCombo = yon_gtk_builder_get_widget(builder,"EncryptionCombo"); + window->KeyStrengthSpin = yon_gtk_builder_get_widget(builder,"KeyStrengthSpin"); + window->ExpireCombo = yon_gtk_builder_get_widget(builder,"ExpireCombo"); + window->ExpireEntry = yon_gtk_builder_get_widget(builder,"ExpireEntry"); + window->ExpireButton = yon_gtk_builder_get_widget(builder,"ExpireButton"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->AddButton = yon_gtk_builder_get_widget(builder,"AddButton"); + + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + g_signal_connect(G_OBJECT(window->ExpireButton),"clicked",G_CALLBACK(on_calendar_open),window); + + int size; + config_str encription_keys = yon_file_open(key_encription_path,&size); + + for (int i=1;iEncryptionCombo),parsed[0]); + yon_char_parsed_free(parsed,parsed_size); + } + return window; +} + +void on_key_clicked(GtkWidget *self, main_window *widgets){ + key_creation_window *window = yon_key_creation_window_new(); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),TITLE_LABEL,icon_path,"key-create-window"); + gtk_widget_show(window->Window); +} + main_window *yon_main_window_complete(main_window *widgets){ widgets = yon_remalloc(widgets,sizeof(main_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); @@ -1148,6 +1191,21 @@ main_window *yon_main_window_complete(main_window *widgets){ widgets->RepoList = GTK_TREE_STORE(gtk_builder_get_object(builder,"RepoStore")); widgets->RepoFileList = GTK_LIST_STORE(gtk_builder_get_object(builder,"RepoFileList")); widgets->RepoPackagesTre = GTK_LIST_STORE(gtk_builder_get_object(builder,"RepoPackagesTre")); + { + widgets->KeyMenuItem = gtk_menu_item_new(); + gtk_menu_shell_prepend(GTK_MENU_SHELL(gtk_widget_get_parent(widgets->AboutMenuItem)),widgets->KeyMenuItem); + GtkWidget *icon = gtk_image_new_from_icon_name(key_icon_name,GTK_ICON_SIZE_BUTTON); + GtkWidget *label = gtk_label_new(KEY_LABEL); + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); + gtk_box_pack_start(GTK_BOX(box),icon,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_container_add(GTK_CONTAINER(widgets->KeyMenuItem),box); + gtk_widget_show_all(widgets->KeyMenuItem); + gtk_style_context_add_class(gtk_widget_get_style_context(widgets->KeyMenuItem),"menuitemtop"); + gtk_style_context_remove_class(gtk_widget_get_style_context(widgets->DocumentationMenuItem),"menuitemtop"); + gtk_style_context_add_class(gtk_widget_get_style_context(widgets->DocumentationMenuItem),"menuitemmiddle"); + g_signal_connect(G_OBJECT(widgets->KeyMenuItem),"activate",G_CALLBACK(on_key_clicked),widgets); + } main_config.tree_store = widgets->RepoList; g_signal_connect(G_OBJECT(widgets->DBConfigurationButton),"clicked",G_CALLBACK(on_storage_configure_clicked),widgets); @@ -1156,7 +1214,7 @@ main_window *yon_main_window_complete(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->RemoveButton),"clicked",G_CALLBACK(on_remove_clicked),widgets); g_signal_connect(G_OBJECT(widgets->ReposTree),"cursor-changed",G_CALLBACK(on_main_tree_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->CloudButton),"clicked",G_CALLBACK(on_ubl_settings_update_launch),widgets); - + yon_calendar_set_date_orientation(1); gtk_window_set_title(GTK_WINDOW(widgets->Window),TITLE_LABEL); diff --git a/source/ubl-settings-repomanager.h b/source/ubl-settings-repomanager.h index e1a41ff..5fd151b 100644 --- a/source/ubl-settings-repomanager.h +++ b/source/ubl-settings-repomanager.h @@ -25,7 +25,8 @@ #define glade_path_repo_add "/com/ublinux/ui/ubl-settings-repomanager-add.glade" #define glade_path_storage_config "/com/ublinux/ui/ubl-settings-repomanager-configuration.glade" #define glade_path_repo_block "/com/ublinux/ui/ubl-settings-repomanager-repo-block.glade" -#define glade_path_filechooser_config "/com/ublinux/ui/ubl-settings-repomanager-filechooser.glade" +#define glade_path_filechooser "/com/ublinux/ui/ubl-settings-repomanager-filechooser.glade" +#define glade_path_key "/com/ublinux/ui/ubl-settings-repomanager-key.glade" #define banner_path "/com/ublinux/images/ubl-settings-repomanager-banner.png" #define CssPath "/com/ublinux/css/ubl-settings-repomanager.css" #define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) @@ -38,9 +39,12 @@ #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-repomanager" + +#define key_icon_name "com.ublinux.libublsettingsui-gtk3.key-symbolic" + +#define key_encription_path "/usr/share/ubl-settings-repomanager/csv/crypt-key.csv" typedef char* string; -#define get_package_info_command(filename) yon_char_unite("LC_ALL=EN pacman -Q --info --file ",filename," |sed -e 's/ */ /g' -e 's/ : /:/g' -e 's/\\n/ /g'",NULL) #define get_saved_package_info_command(path,filename) yon_char_unite("LC_ALL=EN pacman -Q --info --file $(find \"",path,"\" -name \"*",filename,"*\" -not -name *.sig |head -n 1)|sed -e 's/ */ /g' -e 's/ : /:/g' -e 's/\\n/ /g'",NULL) #define get_gpg_keys_command yon_char_unite(yon_ubl_check_root()==1 ? yon_char_unite("su - ",yon_ubl_root_user_get()," -c \"gpg --list-signatures\"",NULL):"gpg --list-signatures"," | grep '^sig 3' | cut -d' ' -f10,11,13- | sort -u |sed -e 's/[0-9]*-[0-9]*-[0-9]* //g'",NULL) @@ -92,6 +96,7 @@ typedef struct { GtkWidget *SearchEntry; GtkWidget *RepoPackagesTree; GtkWidget *InformationLabel; + GtkWidget *KeyMenuItem; GtkTreeStore *RepoList; GtkListStore *RepoFileList; GtkListStore *RepoPackagesTre; @@ -162,6 +167,22 @@ typedef struct { char *root_path; } file_chooser_window; +typedef struct { + GtkWidget *Window; + GtkWidget *StatusBox; + GtkWidget *HeadLabel; + GtkWidget *NameEntry; + GtkWidget *EmailEntry; + GtkWidget *CommentsEntry; + GtkWidget *EncryptionCombo; + GtkWidget *KeyStrengthSpin; + GtkWidget *ExpireCombo; + GtkWidget *ExpireEntry; + GtkWidget *ExpireButton; + GtkWidget *CancelButton; + GtkWidget *AddButton; +} key_creation_window; + main_window *setup_window(); void yon_storage_config_update(storage_config_window *window); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index b7b6961..eed5bd8 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -9,6 +9,8 @@ #define PROJECT_HOME_LABEL _("Project Home Page") #define NOTHING_CHOSEN_LABEL _("Nothing were chosen") +#define KEY_LABEL _("Key creation") + #define LOAD_SUCCESS_LABEL _("Repository data has been loaded successfully") #define SAVE_SUCCESS_LABEL _("Saving has succeeded") diff --git a/ubl-settings-repomanager-key.glade b/ubl-settings-repomanager-key.glade new file mode 100644 index 0000000..01bc6bb --- /dev/null +++ b/ubl-settings-repomanager-key.glade @@ -0,0 +1,403 @@ + + + + + + + 99999999 + 1 + 10 + + + True + False + com.ublinux.libublsettingsui-gtk3.calendar-symbolic + 3 + + + 500 + False + True + com.ublinux.ubl-settings-repomanager + + + True + False + vertical + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + vertical + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + Name: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Email: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 1 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + Commentary: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Encryption type: + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + False + True + 1 + + + + + True + False + 5 + + + True + False + key strength (in bits): + + + False + True + 0 + + + + + True + True + adjustment1 + + + True + True + 1 + + + + + False + True + 2 + + + + + True + False + 5 + + + True + False + Expires: + + + False + True + 0 + + + + + True + False + 0 + + timeless + until + + + + False + True + 1 + + + + + True + True + + + True + True + 2 + + + + + True + True + True + image1 + + + + False + True + 3 + + + + + False + True + 3 + + + + + + + + + True + False + Key additional configuration + + + + + False + True + 2 + + + + + False + True + 0 + + + + + True + True + 1 + + + + + + + True + False + + + True + False + Repository manager + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-repomanager + + + + + Cancel + True + True + True + + + 1 + + + + + Add + True + True + True + + + end + 2 + + + + + +