diff --git a/gresource.xml b/gresource.xml index 8f93c3d..39032f6 100644 --- a/gresource.xml +++ b/gresource.xml @@ -9,6 +9,7 @@ ubl-settings-update-repo-path-add.glade ubl-settings-update-mirror-configure.glade ubl-settings-update-password.glade + ubl-settings-update-ftp-publication.glade ubl-settings-update.css diff --git a/locale/ubl-settings-update.pot b/locale/ubl-settings-update.pot index fe962fb..6bff029 100644 --- a/locale/ubl-settings-update.pot +++ b/locale/ubl-settings-update.pot @@ -185,7 +185,7 @@ msgid "" "commas (,)" msgstr "" -#: source/ubl-strings.h:54 source/ubl-strings.h:82 +#: source/ubl-strings.h:54 source/ubl-strings.h:83 msgid "Update" msgstr "" @@ -217,10 +217,6 @@ msgstr "" msgid "Automatic update" msgstr "" -#: source/ubl-strings.h:62 -msgid "Last update:" -msgstr "" - #: source/ubl-strings.h:63 msgid "Update mode:" msgstr "" @@ -229,150 +225,154 @@ msgstr "" msgid "Update interval:" msgstr "" -#: source/ubl-strings.h:66 -msgid "Update mode" +#: source/ubl-strings.h:65 +msgid "Last update:" msgstr "" #: source/ubl-strings.h:67 -msgid "Update interval" +msgid "Update mode" msgstr "" #: source/ubl-strings.h:68 +msgid "Update interval" +msgstr "" + +#: source/ubl-strings.h:69 msgid "Boot" msgstr "" -#: source/ubl-strings.h:69 source/ubl-strings.h:152 +#: source/ubl-strings.h:70 source/ubl-strings.h:152 msgid "Minutes" msgstr "" -#: source/ubl-strings.h:70 source/ubl-strings.h:153 +#: source/ubl-strings.h:71 source/ubl-strings.h:153 msgid "Hours" msgstr "" -#: source/ubl-strings.h:71 source/ubl-strings.h:154 +#: source/ubl-strings.h:72 source/ubl-strings.h:154 msgid "Days" msgstr "" -#: source/ubl-strings.h:72 source/ubl-strings.h:155 +#: source/ubl-strings.h:73 source/ubl-strings.h:155 msgid "Months" msgstr "" -#: source/ubl-strings.h:73 +#: source/ubl-strings.h:74 msgid "Repositories from which the update will occur" msgstr "" -#: source/ubl-strings.h:74 source/ubl-strings.h:97 +#: source/ubl-strings.h:75 source/ubl-strings.h:98 msgid "Repositories list:" msgstr "" -#: source/ubl-strings.h:75 +#: source/ubl-strings.h:76 msgid "Repositories list" msgstr "" -#: source/ubl-strings.h:76 +#: source/ubl-strings.h:77 msgid "Default" msgstr "" -#: source/ubl-strings.h:77 source/ubl-strings.h:99 +#: source/ubl-strings.h:78 source/ubl-strings.h:100 msgid "Choose" msgstr "" -#: source/ubl-strings.h:78 +#: source/ubl-strings.h:79 msgid "Chosen" msgstr "" -#: source/ubl-strings.h:79 +#: source/ubl-strings.h:80 msgid "Repository" msgstr "" -#: source/ubl-strings.h:80 +#: source/ubl-strings.h:81 msgid "Manage repository list" msgstr "" -#: source/ubl-strings.h:81 +#: source/ubl-strings.h:82 msgid "Disable system repositories" msgstr "" -#: source/ubl-strings.h:83 +#: source/ubl-strings.h:84 msgid "Move up" msgstr "" -#: source/ubl-strings.h:84 +#: source/ubl-strings.h:85 msgid "Move down" msgstr "" -#: source/ubl-strings.h:85 +#: source/ubl-strings.h:86 msgid "Add" msgstr "" -#: source/ubl-strings.h:86 +#: source/ubl-strings.h:87 msgid "Edit" msgstr "" -#: source/ubl-strings.h:87 +#: source/ubl-strings.h:88 msgid "Remove" msgstr "" -#: source/ubl-strings.h:88 +#: source/ubl-strings.h:89 msgid "Enabled" msgstr "" -#: source/ubl-strings.h:89 +#: source/ubl-strings.h:90 msgid "Source" msgstr "" -#: source/ubl-strings.h:90 +#: source/ubl-strings.h:91 msgid "Signature level" msgstr "" -#: source/ubl-strings.h:91 +#: source/ubl-strings.h:92 msgid "Usage level" msgstr "" -#: source/ubl-strings.h:92 +#: source/ubl-strings.h:93 msgid "Repository connection configuration" msgstr "" -#: source/ubl-strings.h:93 +#: source/ubl-strings.h:94 msgid "" "Setting up a connection to a distributed repository network and publishing " "your repositories" msgstr "" -#: source/ubl-strings.h:94 +#: source/ubl-strings.h:95 msgid "Connect and publish" msgstr "" -#: source/ubl-strings.h:95 +#: source/ubl-strings.h:96 msgid "Recieve DB packages from shared network" msgstr "" -#: source/ubl-strings.h:96 +#: source/ubl-strings.h:97 msgid "Repositories for publishing" msgstr "" -#: source/ubl-strings.h:98 +#: source/ubl-strings.h:99 msgid "All repositories" msgstr "" -#: source/ubl-strings.h:100 +#: source/ubl-strings.h:101 msgid "Accept" msgstr "" -#: source/ubl-strings.h:101 +#: source/ubl-strings.h:102 msgid "Repository name" msgstr "" -#: source/ubl-strings.h:102 +#: source/ubl-strings.h:103 msgid "" "Setting up publication of storage and/or repositories as a local WEB resource" msgstr "" -#: source/ubl-strings.h:103 source/ubl-strings.h:144 +#: source/ubl-strings.h:104 source/ubl-strings.h:144 msgid "Authorization parameters" msgstr "" -#: source/ubl-strings.h:104 +#: source/ubl-strings.h:105 msgid "Storage" msgstr "" @@ -611,5 +611,40 @@ msgstr "" msgid "Repeat password" msgstr "" -msgid "Setting up publishing of a repository and/or repositories as a local FTP resource" -mststr "" \ No newline at end of file +#: source/ubl-strings.h:168 +msgid "" +"Setting up publishing of a repository and/or repositories as a local FTP " +"resource" +msgstr "" + +#: source/ubl-strings.h:169 +msgid "Enable publishing of a local repository and as a FTP resource" +msgstr "" + +#: source/ubl-strings.h:170 +msgid "Storage:" +msgstr "" + +#: source/ubl-strings.h:171 +msgid "Anonymous user:" +msgstr "" + +#: source/ubl-strings.h:172 +msgid "Open user list" +msgstr "" + +#: source/ubl-strings.h:173 +msgid "FTP-publication" +msgstr "" + +#: source/ubl-strings.h:174 +msgid "Cancel" +msgstr "" + +#: source/ubl-strings.h:174 +msgid "Check system updates at system startup" +msgstr "" + +#: source/ubl-strings.h:174 +msgid "Remove repository" +msgstr "" diff --git a/locale/ubl-settings-update_ru.po b/locale/ubl-settings-update_ru.po index b8c3b01..e35fd03 100644 --- a/locale/ubl-settings-update_ru.po +++ b/locale/ubl-settings-update_ru.po @@ -204,7 +204,7 @@ msgstr "" "Полный адрес места, где можно найти базу данных, пакеты и подписа (если " "доступны) для этого репозитория. Возможно указать несколько через запятую (,)" -#: source/ubl-strings.h:54 source/ubl-strings.h:82 +#: source/ubl-strings.h:54 source/ubl-strings.h:83 msgid "Update" msgstr "Обновление" @@ -236,10 +236,6 @@ msgstr "Дата последнего автообновления" msgid "Automatic update" msgstr "Автоматическое обновление" -#: source/ubl-strings.h:62 -msgid "Last update:" -msgstr "Последнее обновление:" - #: source/ubl-strings.h:63 msgid "Update mode:" msgstr "Режим обновления:" @@ -248,111 +244,115 @@ msgstr "Режим обновления:" msgid "Update interval:" msgstr "Интервал обновлений:" -#: source/ubl-strings.h:66 +#: source/ubl-strings.h:65 +msgid "Last update:" +msgstr "Последнее обновление:" + +#: source/ubl-strings.h:67 msgid "Update mode" msgstr "Режим обновления" -#: source/ubl-strings.h:67 +#: source/ubl-strings.h:68 msgid "Update interval" msgstr "Интервал обновлений" -#: source/ubl-strings.h:68 +#: source/ubl-strings.h:69 msgid "Boot" msgstr "Запуск" -#: source/ubl-strings.h:69 source/ubl-strings.h:152 +#: source/ubl-strings.h:70 source/ubl-strings.h:152 msgid "Minutes" msgstr "минут" -#: source/ubl-strings.h:70 source/ubl-strings.h:153 +#: source/ubl-strings.h:71 source/ubl-strings.h:153 msgid "Hours" msgstr "часов" -#: source/ubl-strings.h:71 source/ubl-strings.h:154 +#: source/ubl-strings.h:72 source/ubl-strings.h:154 msgid "Days" msgstr "дней" -#: source/ubl-strings.h:72 source/ubl-strings.h:155 +#: source/ubl-strings.h:73 source/ubl-strings.h:155 msgid "Months" msgstr "месяцев" -#: source/ubl-strings.h:73 +#: source/ubl-strings.h:74 msgid "Repositories from which the update will occur" msgstr "Репозитории с которых будет происходить обновление" -#: source/ubl-strings.h:74 source/ubl-strings.h:97 +#: source/ubl-strings.h:75 source/ubl-strings.h:98 msgid "Repositories list:" msgstr "Список репозиториев:" -#: source/ubl-strings.h:75 +#: source/ubl-strings.h:76 msgid "Repositories list" msgstr "Список репозиториев" -#: source/ubl-strings.h:76 +#: source/ubl-strings.h:77 msgid "Default" msgstr "По умолчанию" -#: source/ubl-strings.h:77 source/ubl-strings.h:99 +#: source/ubl-strings.h:78 source/ubl-strings.h:100 msgid "Choose" msgstr "Выбрать" -#: source/ubl-strings.h:78 +#: source/ubl-strings.h:79 msgid "Chosen" msgstr "Выбран" -#: source/ubl-strings.h:79 +#: source/ubl-strings.h:80 msgid "Repository" msgstr "Репозиторий" -#: source/ubl-strings.h:80 +#: source/ubl-strings.h:81 msgid "Manage repository list" msgstr "Управление списком репозиториев" -#: source/ubl-strings.h:81 +#: source/ubl-strings.h:82 msgid "Disable system repositories" msgstr "Отключить системные репозитории" -#: source/ubl-strings.h:83 +#: source/ubl-strings.h:84 msgid "Move up" msgstr "Переместить выше" -#: source/ubl-strings.h:84 +#: source/ubl-strings.h:85 msgid "Move down" msgstr "Переместить ниже" -#: source/ubl-strings.h:85 +#: source/ubl-strings.h:86 msgid "Add" msgstr "Добавить" -#: source/ubl-strings.h:86 +#: source/ubl-strings.h:87 msgid "Edit" msgstr "Изменить" -#: source/ubl-strings.h:87 +#: source/ubl-strings.h:88 msgid "Remove" msgstr "Удалить" -#: source/ubl-strings.h:88 +#: source/ubl-strings.h:89 msgid "Enabled" msgstr "Включен" -#: source/ubl-strings.h:89 +#: source/ubl-strings.h:90 msgid "Source" msgstr "Источник" -#: source/ubl-strings.h:90 +#: source/ubl-strings.h:91 msgid "Signature level" msgstr "Уровень подписи" -#: source/ubl-strings.h:91 +#: source/ubl-strings.h:92 msgid "Usage level" msgstr "Уровень использования" -#: source/ubl-strings.h:92 +#: source/ubl-strings.h:93 msgid "Repository connection configuration" msgstr "Настройки подключения репозитория" -#: source/ubl-strings.h:93 +#: source/ubl-strings.h:94 msgid "" "Setting up a connection to a distributed repository network and publishing " "your repositories" @@ -360,42 +360,42 @@ msgstr "" "Настройки подключения к распределённой сети репозиториев и публикация своих " "репозиториев" -#: source/ubl-strings.h:94 +#: source/ubl-strings.h:95 msgid "Connect and publish" msgstr "Подключиться и опубликовать" -#: source/ubl-strings.h:95 +#: source/ubl-strings.h:96 msgid "Recieve DB packages from shared network" msgstr "Получать БД пакетов из распределённой сети" -#: source/ubl-strings.h:96 +#: source/ubl-strings.h:97 msgid "Repositories for publishing" msgstr "Репозитории для публикации" -#: source/ubl-strings.h:98 +#: source/ubl-strings.h:99 msgid "All repositories" msgstr "Все репозитории" -#: source/ubl-strings.h:100 +#: source/ubl-strings.h:101 msgid "Accept" msgstr "Принять" -#: source/ubl-strings.h:101 +#: source/ubl-strings.h:102 msgid "Repository name" msgstr "Имя репозитория" -#: source/ubl-strings.h:102 +#: source/ubl-strings.h:103 msgid "" "Setting up publication of storage and/or repositories as a local WEB resource" msgstr "" "Настройка публикации хранилища и/или репозиториев в виде локального WEB " "ресурса" -#: source/ubl-strings.h:103 source/ubl-strings.h:144 +#: source/ubl-strings.h:104 source/ubl-strings.h:144 msgid "Authorization parameters" msgstr "Параметры авторизации" -#: source/ubl-strings.h:104 +#: source/ubl-strings.h:105 msgid "Storage" msgstr "Хранилище" @@ -641,20 +641,45 @@ msgstr "Пароль" msgid "Repeat password" msgstr "Подтвердите ввод пароля" -msgid "Check system updates at system startup" -msgstr "Проверять обновления при загрузке системы" +#: source/ubl-strings.h:168 +msgid "" +"Setting up publishing of a repository and/or repositories as a local FTP " +"resource" +msgstr "" +"Настройка публикации хранилища и/или репозиториев в виде локального FTP " +"ресурса" -msgid "days" -msgstr "дней" +#: source/ubl-strings.h:169 +msgid "Enable publishing of a local repository and as a FTP resource" +msgstr "Включить публикацию локального репозитория в виде FTP ресурса" -msgid "Cancel" -msgstr "Отмена" +#: source/ubl-strings.h:170 +msgid "Storage:" +msgstr "Хранилище:" + +#: source/ubl-strings.h:171 +msgid "Anonymous user" +msgstr "Аноноимный пользователь" + +#: source/ubl-strings.h:171 +msgid "Anonymous user:" +msgstr "Аноноимный пользователь:" +#: source/ubl-strings.h:172 +msgid "Open user list" +msgstr "Открыть список пользователей" + +#: source/ubl-strings.h:173 msgid "FTP-publication" msgstr "FTP-публикация" -msgid "Anonymous user" -msgstr "Аноноимный пользователь" +#: source/ubl-strings.h:174 +msgid "Cancel" +msgstr "Отмена" + +msgid "Check system updates at system startup" +msgstr "Проверять обновления при загрузке системы" -msgid "Setting up publishing of a repository and/or repositories as a local FTP resource" -msgstr "Настройка публикации хранилища и/или репозиториев в виде локального FTP ресурса" \ No newline at end of file +#: source/ubl-strings.h:174 +msgid "Remove repository" +msgstr "Удалить репозиторий" diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index ee87502..b6d519b 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -39,6 +39,7 @@ set(DEPENDFILES ../ubl-settings-update-repo-path-add.glade ../ubl-settings-update-mirror-configure.glade ../ubl-settings-update-password.glade + ../ubl-settings-update-ftp-publication.glade ../gresource.xml ../ubl-settings-update.css ) diff --git a/source/ubl-settings-update-ftp.c b/source/ubl-settings-update-ftp.c index e476ff5..1fb6b09 100644 --- a/source/ubl-settings-update-ftp.c +++ b/source/ubl-settings-update-ftp.c @@ -1,8 +1,83 @@ #include "ubl-settings-update.h" -void on_ftp_accept(GtkWidget *, ftp_window *){ +void on_ftp_accept(GtkWidget *, ftp_window *window){ + main_window *widgets = g_object_get_data(G_OBJECT(window->AcceptButton),"main_window"); + GtkTreeIter iter; + const char *storage_path = gtk_entry_get_text(GTK_ENTRY(window->StorageEntry)); + if (yon_char_is_empty(storage_path)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->StorageEntry); + return; + } + char *port = NULL; + gboolean enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->EnableCheck)); + const char *user = NULL; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PortCheck))){ + port = yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->PortSpin))); + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->AnonUserCheck))){ + user = gtk_entry_get_text(GTK_ENTRY(window->AnonUserEntry)); + if (yon_char_is_empty(user)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),_EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->AnonUserEntry); + return; + } + } + char *repos = NULL; + for_iter(window->ReposList,&iter){ + int active; + char *target; + gtk_tree_model_get(GTK_TREE_MODEL(window->ReposList),&iter,0,&active,1,&target,-1); + if (active){ + char *temp = yon_char_append_element(repos,target,","); + if (!yon_char_is_empty(repos)) free(repos); + repos = temp; + } + } + if (yon_char_is_empty(repos)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),NOTHING_CHOSEN_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(window->ReposTree)); + return; + } + char *id_string = yon_char_unite(storage_path,":",repos,NULL); + int size; + config_str parameters = yon_char_parsed_new(&size,enable? "yes":"no", + yon_char_return_if_exist(port,""), + yon_char_return_if_exist(user,""), + NULL); + char *parameter_string = yon_char_parsed_to_string(parameters,size,":"); + + char *parameter_name = REPOPUBLIC_FTP(id_string); + char *parameter_command = REPOPUBLIC_FTP_command(id_string); + if (!yon_char_is_empty(window->prev_key)&&strcmp(id_string,window->prev_key)){ + char *old_parameter = REPOPUBLIC_FTP(window->prev_key); + yon_config_remove_by_key(old_parameter); + free(old_parameter); + } + yon_config_register(parameter_name,parameter_command,parameter_string); + free(window->prev_key); + free(id_string); + free(parameter_string); + free(parameter_name); + free(parameter_command); + if (!yon_char_is_empty(port)) free(port); + if (!yon_char_is_empty(repos)) free(repos); + on_subwindow_close(window->Window); + free(window); + yon_interface_update(widgets); +} + +void on_anon_user_select(GtkWidget *, ftp_window *window){ + unsigned int size; + config_str users = yon_users_window_select(YON_USER_WINDOW_USERS,&size); + if (size){ + char *users_string = yon_char_parsed_to_string(users,size," "); + gtk_entry_set_text(GTK_ENTRY(window->AnonUserEntry),users_string); + free(users_string); + yon_char_parsed_free(users,size); + } } ftp_window *yon_ftp_window_new(){ @@ -24,15 +99,93 @@ ftp_window *yon_ftp_window_new(){ window->AnonUserButton = yon_gtk_builder_get_widget(builder,"AnonUserButton"); window->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton"); window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->ReposList = GTK_LIST_STORE(gtk_builder_get_object(builder,"ReposList")); + window->SelectionCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"SelectionCell")); + g_signal_connect(G_OBJECT(window->SelectionCell),"toggled",G_CALLBACK(on_cell_renderer_toggle_toggled),window->ReposTree); + g_signal_connect(G_OBJECT(window->StorageButton),"clicked",G_CALLBACK(on_file_chooser_open),window->StorageEntry); + g_signal_connect(G_OBJECT(window->StorageEntry),"changed",G_CALLBACK(on_web_publish_path_changed),window); + g_signal_connect(G_OBJECT(window->PortCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->PortSpin); + g_signal_connect(G_OBJECT(window->AnonUserCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->AnonUserEntry); + g_signal_connect(G_OBJECT(window->AnonUserCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->AnonUserButton); + g_signal_connect(G_OBJECT(window->AnonUserButton),"clicked",G_CALLBACK(on_anon_user_select),window); + + g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_ftp_accept),window); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); - g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_ftp_accept),NULL); return window; } -void yon_ftp_window_open(GtkWidget *, main_window *widgets){ +void yon_ftp_window_add(GtkWidget *, main_window *widgets){ ftp_window *window = yon_ftp_window_new(); g_object_set_data(G_OBJECT(window->AcceptButton),"main_window",widgets); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),NULL,icon_path,"ftp_window"); + +} + +void yon_ftp_window_edit(GtkWidget *, main_window *widgets){ + GtkTreeModel *model; + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->FtpTree)),&model,&iter)){ + ftp_window *window = yon_ftp_window_new(); + g_object_set_data(G_OBJECT(window->AcceptButton),"main_window",widgets); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),NULL,icon_path,"ftp_window"); + char *storage; + char *repos; + gtk_tree_model_get(model,&iter,1,&storage,2,&repos,-1); + char *repos_replaced = yon_char_replace(repos,"\n",","); + char *parameter_key = yon_char_unite(storage,":",repos_replaced,NULL); + window->prev_key = yon_char_new(parameter_key); + char *parameter_name = REPOPUBLIC_FTP(parameter_key); + char *parameter = config(parameter_name); + if (parameter){ + int size; + config_str parsed = yon_char_parse(parameter,&size,":"); + if (size>0&&!yon_char_is_empty(parsed[0])){ + if (!strcmp(parsed[0],"enabled")||!strcmp(parsed[0],"yes")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->EnableCheck),1); + } + } + if (size>1&&!yon_char_is_empty(parsed[1])){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->PortCheck),1); + gtk_adjustment_set_value(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(window->PortSpin)),atol(parsed[1])); + } + if (size>2&&!yon_char_is_empty(parsed[2])){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->AnonUserCheck),1); + gtk_entry_set_text(GTK_ENTRY(window->AnonUserEntry),parsed[2]); + } + } + gtk_entry_set_text(GTK_ENTRY(window->StorageEntry),storage); + for_iter (window->ReposList,&iter){ + char *target; + gtk_tree_model_get(GTK_TREE_MODEL(window->ReposList),&iter,1,&target,-1); + if (yon_char_check_element(repos_replaced,target,",")){ + gtk_list_store_set(window->ReposList,&iter,0,1,-1); + } + } + } + +} +void on_ftp_remove(GtkWidget *,main_window *widgets){ + GtkTreeModel *model; + GtkTreeIter iter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->FtpTree)),&model,&iter)){ + dialog_confirmation_data *data = yon_confirmation_dialog_data_new(); + data->title = REMOVE_FTP_TITLE_LABEL; + data->action_text = REMOVE_REPO_WARNING_LABEL; + if (yon_confirmation_dialog_call(widgets->Window,data)!=GTK_RESPONSE_CANCEL){ + char *storage; + char *repos; + gtk_tree_model_get(model,&iter,1,&storage,2,&repos,-1); + char *repos_replaced = yon_char_replace(repos,"\n",","); + char *parameter_key = yon_char_unite(storage,":",repos_replaced,NULL); + char *parameter = REPOPUBLIC_FTP(parameter_key); + yon_config_remove_by_key(parameter); + free(parameter); + free(parameter_key); + free(repos_replaced); + yon_interface_update(widgets); + } + } } \ No newline at end of file diff --git a/source/ubl-settings-update.c b/source/ubl-settings-update.c index ae53fe9..e89935b 100644 --- a/source/ubl-settings-update.c +++ b/source/ubl-settings-update.c @@ -516,6 +516,34 @@ void yon_interface_update(main_window *widgets){ } } } + { + gtk_list_store_clear(widgets->FtpList); + int size; + config_str ftp_parameters = yon_config_get_all_by_key(REPOPUBLIC_FTP_search,&size); + for (int i=0;i0&&(!strcmp(parsed[0],"enable")||!strcmp(parsed[0],"yes")); + char *port = NULL; + if (parsed_size>1&&!yon_char_is_empty(parsed[1])){ + port = parsed[1]; + } + char *user = NULL; + if (parsed_size>2&&!yon_char_is_empty(parsed[2])){ + user = parsed[2]; + } + gtk_list_store_append(widgets->FtpList,&iter); + gtk_list_store_set(widgets->FtpList,&iter,0,enabled,1,storage,2,repos,3,port,4,user,-1); + yon_char_parsed_free(parsed,parsed_size); + } + yon_char_parsed_free(ftp_parameters,size); + } } // standard functions @@ -608,6 +636,14 @@ void on_selection_changed(GtkWidget *self, main_window *widgets){ gtk_widget_set_sensitive(widgets->MirrorEditButton,0); gtk_widget_set_sensitive(widgets->MirrorRemoveButton,0); } + } else if (self == widgets->FtpTree){ + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->FtpTree)),&model,&iter)){ + gtk_widget_set_sensitive(widgets->FtpEditButton,1); + gtk_widget_set_sensitive(widgets->FtpRemoveButton,1); + } else { + gtk_widget_set_sensitive(widgets->FtpEditButton,0); + gtk_widget_set_sensitive(widgets->FtpRemoveButton,0); + } } } @@ -1300,6 +1336,11 @@ void yon_main_window_complete(main_window *widgets){ widgets->WebPublicationEditButton = yon_gtk_builder_get_widget(builder,"WebPublicationEditButton"); widgets->WebPublicationRemoveButton = yon_gtk_builder_get_widget(builder,"WebPublicationRemoveButton"); widgets->WebPublicationTree = yon_gtk_builder_get_widget(builder,"WebPublicationTree"); + widgets->FtpUpdateButton = yon_gtk_builder_get_widget(builder,"FtpUpdateButton"); + widgets->FtpAddButton = yon_gtk_builder_get_widget(builder,"FtpAddButton"); + widgets->FtpRemoveButton = yon_gtk_builder_get_widget(builder,"FtpRemoveButton"); + widgets->FtpEditButton = yon_gtk_builder_get_widget(builder,"FtpEditButton"); + widgets->FtpTree = yon_gtk_builder_get_widget(builder,"FtpTree"); widgets->MirrorPublicCheck = yon_gtk_builder_get_widget(builder,"MirrorPublicCheck"); widgets->MirrorTree = yon_gtk_builder_get_widget(builder,"MirrorTree"); widgets->MirrorUpdateButton = yon_gtk_builder_get_widget(builder,"MirrorUpdateButton"); @@ -1314,6 +1355,7 @@ void yon_main_window_complete(main_window *widgets){ widgets->ReposList = GTK_LIST_STORE(gtk_builder_get_object(builder,"ReposList")); widgets->PublicationList = GTK_LIST_STORE(gtk_builder_get_object(builder,"PublicationList")); widgets->WebPublicationList = GTK_LIST_STORE(gtk_builder_get_object(builder,"WebPublicationList")); + widgets->FtpList = GTK_LIST_STORE(gtk_builder_get_object(builder,"FtpList")); widgets->MirrorList = GTK_LIST_STORE(gtk_builder_get_object(builder,"MirrorList")); } { @@ -1321,17 +1363,21 @@ void yon_main_window_complete(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->RepositoriesMoveDownButton),"clicked",G_CALLBACK(on_repo_move_down),widgets); g_signal_connect(G_OBJECT(widgets->RepositoriesCreateButton),"clicked",G_CALLBACK(on_repo_add),widgets); g_signal_connect(G_OBJECT(widgets->WebPublicationAddButton),"clicked",G_CALLBACK(on_web_publish_add),widgets); + g_signal_connect(G_OBJECT(widgets->FtpAddButton),"clicked",G_CALLBACK(yon_ftp_window_add),widgets); g_signal_connect(G_OBJECT(widgets->MirrorAddButton),"clicked",G_CALLBACK(on_mirror_add),widgets); g_signal_connect(G_OBJECT(widgets->RepositoriesDeleteButton),"clicked",G_CALLBACK(on_repo_remove),widgets); g_signal_connect(G_OBJECT(widgets->WebPublicationRemoveButton),"clicked",G_CALLBACK(on_web_publish_remove),widgets); + g_signal_connect(G_OBJECT(widgets->FtpRemoveButton),"clicked",G_CALLBACK(on_ftp_remove),widgets); g_signal_connect(G_OBJECT(widgets->MirrorRemoveButton),"clicked",G_CALLBACK(on_mirror_remove),widgets); g_signal_connect(G_OBJECT(widgets->RepositoriesTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->PublicationTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->WebPublicationTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); + g_signal_connect(G_OBJECT(widgets->FtpTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->MirrorTree),"cursor-changed",G_CALLBACK(on_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->MirrorEditButton),"clicked",G_CALLBACK(on_mirror_edit),widgets); g_signal_connect(G_OBJECT(widgets->WebPublicationEditButton),"clicked",G_CALLBACK(on_web_publish_edit),widgets); + g_signal_connect(G_OBJECT(widgets->FtpEditButton),"clicked",G_CALLBACK(yon_ftp_window_edit),widgets); g_signal_connect(G_OBJECT(widgets->RepositoriesEditButton),"clicked",G_CALLBACK(on_repo_edit),widgets); g_signal_connect(G_OBJECT(widgets->MirrorConfigureButton),"clicked",G_CALLBACK(on_mirror_configure),widgets); @@ -1357,6 +1403,7 @@ void yon_main_window_complete(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->RepositoriesUpdateButton),"clicked",G_CALLBACK(on_update_clicked),widgets); g_signal_connect(G_OBJECT(widgets->PublicationUpdateButton),"clicked",G_CALLBACK(on_update_clicked),widgets); g_signal_connect(G_OBJECT(widgets->WebPublicationUpdateButton),"clicked",G_CALLBACK(on_update_clicked),widgets); + g_signal_connect(G_OBJECT(widgets->FtpUpdateButton),"clicked",G_CALLBACK(on_update_clicked),widgets); g_signal_connect(G_OBJECT(widgets->MirrorUpdateButton),"clicked",G_CALLBACK(on_update_clicked),widgets); // g_signal_connect(G_OBJECT(widgets->RepositoriesDisableSystemReposCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->RepositoriesTree); diff --git a/source/ubl-settings-update.h b/source/ubl-settings-update.h index 887c72c..6df50ae 100644 --- a/source/ubl-settings-update.h +++ b/source/ubl-settings-update.h @@ -32,7 +32,7 @@ #define glade_mirror_path_add_path "/com/ublinux/ui/ubl-settings-update-mirror-path-add.glade" #define glade_repo_path_add_path "/com/ublinux/ui/ubl-settings-update-repo-path-add.glade" #define glade_password_path "/com/ublinux/ui/ubl-settings-update-password.glade" -#define glade_path_ftp "/com/ublinux/ui/ubl-settings-update-ftp.glade" +#define glade_path_ftp "/com/ublinux/ui/ubl-settings-update-ftp-publication.glade" #define CssPath "/com/ublinux/css/ubl-settings-update.css" #define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) @@ -61,6 +61,12 @@ #define REPOSITORY_parameter_command yon_char_unite("ubconfig --source global get [update] REPOSITORY",NULL) #define REPOSITORY_search "REPOSITORY[" +#define REPOPUBLIC_FTP(target) yon_char_unite("REPOPUBLIC_FTP[",target,"]",NULL) +#define REPOPUBLIC_FTP_parameter "REPOPUBLIC_FTP[*]" +#define REPOPUBLIC_FTP_search "REPOPUBLIC_FTP[" +#define REPOPUBLIC_FTP_command(target) yon_char_unite("ubconfig --source global get [update] REPOPUBLIC_FTP[",target,"]",NULL) +#define REPOPUBLIC_FTP_command_all "ubconfig --source global get [update] REPOPUBLIC_FTP[*]" + #define REPOPUBLIC_NET_parameter "REPOPUBLIC_NET" #define REPOPUBLIC_NET_parameter_command "ubconfig --source global get [update] REPOPUBLIC_NET" #define REPOPUBLIC_WEB "REPOPUBLIC_WEB" @@ -151,6 +157,13 @@ typedef struct { GtkWidget *WebPublicationUpperTree; GtkListStore *WebPublicationList; + GtkWidget *FtpUpdateButton; + GtkWidget *FtpAddButton; + GtkWidget *FtpEditButton; + GtkWidget *FtpRemoveButton; + GtkWidget *FtpTree; + GtkListStore *FtpList; + GtkWidget *MirrorPublicCheck; GtkWidget *MirrorTree; GtkWidget *MirrorUpdateButton; @@ -196,11 +209,13 @@ typedef struct { } repo_add_window; typedef struct { + GtkListStore *list; + GtkWidget *PathEntry; + GtkWidget *Window; GtkWidget *HeadLabel; GtkWidget *StatusBox; GtkWidget *EnablePublishCheck; - GtkWidget *PathEntry; GtkWidget *PathButton; GtkWidget *RepositoriesTree; GtkWidget *PortCheck; @@ -214,7 +229,6 @@ typedef struct { GtkWidget *PasswordButton; GtkWidget *AcceptButton; GtkWidget *CancelButton; - GtkListStore *list; GtkCellRenderer *SelectionCellRenderer; char *name; @@ -304,10 +318,12 @@ typedef struct { } path_section; typedef struct { + GtkListStore *ReposList; + GtkWidget *StorageEntry; + GtkWidget *Window; GtkWidget *StatusBox; GtkWidget *EnableCheck; - GtkWidget *StorageEntry; GtkWidget *StorageButton; GtkWidget *ReposTree; GtkWidget *PortCheck; @@ -317,6 +333,10 @@ typedef struct { GtkWidget *AnonUserButton; GtkWidget *CancelButton; GtkWidget *AcceptButton; + + GtkCellRenderer *SelectionCell; + + char *prev_key; } ftp_window; @@ -411,5 +431,8 @@ void on_save_start(main_window *widgets, char* path); void on_repo_file_chooser_open(GtkWidget *, repo_add_window *window); void on_ftp_accept(GtkWidget *, ftp_window *); ftp_window *yon_ftp_window_new(); -void yon_ftp_window_open(GtkWidget *, main_window *widgets); +void yon_ftp_window_add(GtkWidget *, main_window *widgets); +void on_anon_user_select(GtkWidget *, ftp_window *window); +void yon_ftp_window_edit(GtkWidget *, main_window *widgets); +void on_ftp_remove(GtkWidget *,main_window *widgets); #endif \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 225a7c4..674f2b7 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -32,6 +32,7 @@ Configuration - configuration path") http_proxy - proxy-server for repository, replaces 'http_proxy'. Single parameter per repository\n\ mirrorlist - mirrors file, make sure server URL is NOT included in this file! Single parameter per repository") #define PASSWORD_INPUT_LABEL _("Password input") + #define REMOVE_FTP_TITLE_LABEL _("Remove repository") /* #define _LABEL _("Signature verification will not be performed") @@ -165,7 +166,15 @@ mirrorlist - mirrors file, make sure server URL is NOT included in this file! Si #define _LABEL _("Encryption") #define _LABEL _("Password") #define _LABEL _("Repeat password") - #define _LABEL _("Setting up publishing of a repository and/or repositories as a local WEB resource") + #define _LABEL _("Setting up publishing of a repository and/or repositories as a local FTP resource") + #define _LABEL _("Enable publishing of a local repository and as a FTP resource") + #define _LABEL _("Storage:") + #define _LABEL _("Anonymous user:") + #define _LABEL _("Anonymous user") + #define _LABEL _("Open user list") + #define _LABEL _("FTP-publication") + #define _LABEL _("Cancel") + #define _LABEL _("Check system updates at system startup") */ #endif \ No newline at end of file diff --git a/ubl-settings-update-ftp-publication.glade b/ubl-settings-update-ftp-publication.glade new file mode 100644 index 0000000..e870698 --- /dev/null +++ b/ubl-settings-update-ftp-publication.glade @@ -0,0 +1,367 @@ + + + + + + + + + + + + + + + 65535 + 8080 + 1 + 10 + + + True + False + com.ublinux.libublsettingsui-gtk3.accept-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.cancel-uncolored-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.zoom-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.avatar-symbolic + + + 450 + 350 + True + False + center-on-parent + com.ublinux.ubl-settings-update + + + True + False + vertical + + + True + False + vertical + 5 + + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + vertical + 5 + + + Enable publishing of a local repository and as a FTP resource + True + True + False + True + + + False + True + 1 + + + + + True + False + 5 + + + True + False + Storage: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + Open file explorer + image3 + + + + False + True + 2 + + + + + False + True + 2 + + + + + True + True + in + + + True + True + ReposList + 1 + both + + + + + + Chosen + + + + 0 + + + + + + + Repository name + + + + 1 + + + + + + + + + True + True + 3 + + + + + True + False + 5 + + + True + False + Port: + + + False + True + 0 + + + + + True + True + False + True + + + + + + False + True + 1 + + + + + True + False + True + adjustment1 + 8080 + + + False + True + 2 + + + + + False + True + 4 + + + + + True + False + 5 + + + True + False + Anonymous user: + + + False + True + 0 + + + + + True + True + False + True + + + + + + False + True + 1 + + + + + True + False + True + + + True + True + 2 + + + + + True + False + True + True + Open user list + image4 + + + + False + True + 3 + + + + + False + True + 5 + + + + + True + True + 1 + + + + + + + True + False + 5 + + + True + False + 5 + 5 + 5 + 5 + 2 + Add repository for publication + + + + + + + + Cancel + True + True + True + image2 + + + + + Accept + True + True + True + image1 + + + end + 1 + + + + + + diff --git a/ubl-settings-update-mirror-configure.glade b/ubl-settings-update-mirror-configure.glade index 8ed890f..c5355c0 100644 --- a/ubl-settings-update-mirror-configure.glade +++ b/ubl-settings-update-mirror-configure.glade @@ -437,7 +437,7 @@ True False - The number of consecutie days that systems on the network have not been updated: + The number of consecutive days that systems on the network have not been updated: False diff --git a/ubl-settings-update.glade b/ubl-settings-update.glade index b962515..a552f35 100644 --- a/ubl-settings-update.glade +++ b/ubl-settings-update.glade @@ -27,15 +27,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + - + - + - + - + @@ -1559,7 +1559,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. vertical 5 - + 26 26 True @@ -1589,7 +1589,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + 26 26 True @@ -1608,7 +1608,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + 26 26 True @@ -1628,7 +1628,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + 26 26 True @@ -1660,11 +1660,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True in - + True True FtpList both + + + Enabled