Shutdown parameter WIP

pull/235/head
parent 3c763b8a34
commit ff7573e76c

@ -87,6 +87,38 @@ void on_additional_settings_changed(GtkWidget *self, ubl_settings_usergroups_add
// }
}
void on_additional_settings_user_sync_add(GtkWidget *, ubl_settings_usergroups_additional_settings_window *){
}
void on_additional_settings_user_sync_remove(GtkWidget *, ubl_settings_usergroups_additional_settings_window *window){
GtkTreeModel *model;
GtkTreeIter iter;
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->UsersTree)),&model,&iter)){
gboolean is_indeletable;
gtk_tree_model_get(model,&iter,4,&is_indeletable,-1);
if (!is_indeletable){
gtk_list_store_remove(window->UsersShutdownList,&iter);
}
}
}
void on_additional_settings_group_sync_add(GtkWidget *, ubl_settings_usergroups_additional_settings_window *){
}
void on_additional_settings_group_sync_remove(GtkWidget *, ubl_settings_usergroups_additional_settings_window *window){
GtkTreeModel *model;
GtkTreeIter iter;
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->GroupsTree)),&model,&iter)){
gboolean is_indeletable;
gtk_tree_model_get(model,&iter,4,&is_indeletable,-1);
if (!is_indeletable){
gtk_list_store_remove(window->GroupsShutdownList,&iter);
}
}
}
ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_additional_settings_new(){
ubl_settings_usergroups_additional_settings_window *window = malloc(sizeof(ubl_settings_usergroups_additional_settings_window));
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_ubl_settings_usergroups_additional_settings);
@ -116,6 +148,8 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_
window->GroupsTree=yon_gtk_builder_get_widget(builder,"GroupsTree");
window->GroupAddButton=yon_gtk_builder_get_widget(builder,"GroupAddButton");
window->GroupRemoveButton=yon_gtk_builder_get_widget(builder,"GroupRemoveButton");
window->UsersShutdownList=GTK_LIST_STORE(gtk_builder_get_object(builder,"UsersShutdownList"));
window->GroupsShutdownList=GTK_LIST_STORE(gtk_builder_get_object(builder,"GroupsShutdownList"));
window->default_password=NULL;
window->default_root_password=NULL;
@ -124,6 +158,16 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_
window->user_shutdown=-1;
window->user_boot=-1;
window->password_hash=NULL;
g_signal_connect(G_OBJECT(window->UserAddButton),"clicked",G_CALLBACK(on_additional_settings_user_sync_add),window);
g_signal_connect(G_OBJECT(window->UserRemoveButton),"clicked",G_CALLBACK(on_additional_settings_user_sync_remove),window);
g_signal_connect(G_OBJECT(window->GroupAddButton),"clicked",G_CALLBACK(on_additional_settings_group_sync_add),window);
g_signal_connect(G_OBJECT(window->GroupRemoveButton),"clicked",G_CALLBACK(on_additional_settings_group_sync_remove),window);
g_signal_connect(G_OBJECT(window->UsersShutdownSwitch),"activate",G_CALLBACK(on_additional_settings_changed),window);
g_signal_connect(G_OBJECT(window->GroupsShutdownSwitch),"activate",G_CALLBACK(on_additional_settings_changed),window);
yon_gtk_revealer_set_from_switch(GTK_REVEALER(window->UserShutdownRevealer),GTK_SWITCH(window->UsersShutdownSwitch));
yon_gtk_revealer_set_from_switch(GTK_REVEALER(window->GroupShutdownRevealer),GTK_SWITCH(window->GroupsShutdownSwitch));
yon_window_config_custom_window_setup(GTK_WINDOW(window->Window),"AdditionalSettingsWindow");
gtk_window_set_title(GTK_WINDOW(window->Window),ADDITIONAL_SETTINGS_TITLE_LABEL);
@ -211,10 +255,14 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_
int sync_parsed_size;
config_str sync_parsed = yon_char_parse(sync_parameters[j],&sync_parsed_size,":");
int cur_size;
int yes = yon_parameter_check_tag(parsed[i],sync_parsed[0]);
if (yes) {
config_str cur = yon_parameter_get_by_template(parsed[i],sync_parameters[i],&cur_size);
if (cur){};
int sync_check = yon_parameter_check_tag(parsed[i],sync_parsed[0]);
if (sync_check) {
config_str cur = yon_parameter_get_by_template(parsed[i],sync_parsed[0],&cur_size);
if (cur){
GtkTreeIter iter;
gtk_list_store_append(window->UsersShutdownList,&iter);
gtk_list_store_set(window->UsersShutdownList,&iter,1,sync_parsed[0],2,cur[0],3,cur_size>1?cur[1]:"",-1);
};
}
yon_char_parsed_free(sync_parsed,sync_parsed_size);
}
@ -248,11 +296,7 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_
g_signal_connect(G_OBJECT(window->PasswordHashCombo),"changed",G_CALLBACK(on_additional_settings_changed),window);
g_signal_connect(G_OBJECT(window->DefaultUserAdministratorCheck),"toggled",G_CALLBACK(on_additional_settings_changed),window);
g_signal_connect(G_OBJECT(window->UsersBootCheck),"toggled",G_CALLBACK(on_additional_settings_changed),window);
g_signal_connect(G_OBJECT(window->UsersShutdownSwitch),"activate",G_CALLBACK(on_additional_settings_changed),window);
g_signal_connect(G_OBJECT(window->GroupsBootCheck),"toggled",G_CALLBACK(on_additional_settings_changed),window);
g_signal_connect(G_OBJECT(window->GroupsShutdownSwitch),"activate",G_CALLBACK(on_additional_settings_changed),window);
yon_gtk_revealer_set_from_switch(GTK_REVEALER(window->UserShutdownRevealer),GTK_SWITCH(window->UsersShutdownSwitch));
yon_gtk_revealer_set_from_switch(GTK_REVEALER(window->GroupShutdownRevealer),GTK_SWITCH(window->GroupsShutdownSwitch));
// g_signal_connect(G_OBJECT(window->UsersBootCheck),"toggled",G_CALLBACK(on_users_boot_toggled),NULL);
// g_signal_connect(G_OBJECT(window->UsersShutdownCheck),"toggled",G_CALLBACK(on_users_shutdown_toggled),NULL);
@ -290,7 +334,7 @@ config_str yon_parameter_parse(char *parameter, int *size){
}
int yon_parameter_check_tag(char *parameter, char *pattern){
char *tag_template = "<([^>]+)>";
char *tag_template = "[0-9]{1,}";
char *converted = "";
char *current = pattern;
while (!yon_char_is_empty(current)){
@ -314,7 +358,9 @@ int yon_parameter_check_tag(char *parameter, char *pattern){
if (regex){
GMatchInfo *match;
if (g_regex_match(regex,parameter,0,&match)){
return 1;
char *value = g_match_info_fetch(match, 0);
if (!strcmp(parameter,value))
return 1;
}
}
@ -324,7 +370,7 @@ int yon_parameter_check_tag(char *parameter, char *pattern){
config_str yon_parameter_get_by_template(char *parameter, char *pattern, int *size){
config_str final = NULL;
char *tag_template = "<([^>]+)>";
char *tag_template = "[0-9]{1,}";
char *converted = "";
char *current = pattern;
while (!yon_char_is_empty(current)){
@ -337,20 +383,23 @@ config_str yon_parameter_get_by_template(char *parameter, char *pattern, int *si
// закрытие тэга не найдено
}
} else {
yon_char_append_c(converted,*current);
char *temp = yon_char_append_c(converted,*current);
if (!yon_char_is_empty(converted)) free(converted);
converted=temp;
current++;
}
}
GRegex *regex = g_regex_new(converted,G_REGEX_EXTENDED,0,NULL);
GRegex *regex = g_regex_new("[0-9]{1,}",G_REGEX_EXTENDED,0,NULL);
if (regex){
GMatchInfo *match;
if (g_regex_match(regex,parameter,0,&match)){
int match_count = g_match_info_get_match_count(match);
for (int i=0;i<match_count;i++){
char *value = g_match_info_fetch(match,i);
yon_char_parsed_add_or_create_if_exists(final,size,value);
}
}
if (g_regex_match(regex, parameter, 0, &match)) {
while (g_match_info_matches(match)) {
char *value = g_match_info_fetch(match, 0);
yon_char_parsed_add_or_create_if_exists(final, size, value);
g_free(value);
g_match_info_next(match, NULL);
}
}
g_match_info_free(match);
}
g_regex_unref(regex);

@ -70,13 +70,13 @@ int yon_load_proceed(YON_CONFIG_TYPE type){
if (!yon_char_is_empty(file)){
path=file;
}
yon_config_clean();
yon_config_load_config(type,config_get_command(path),NULL);
gtk_widget_destroy(dialog);
} else {
gtk_widget_destroy(dialog);
return 0;
}
yon_config_clean();
yon_config_load_config(type,config_get_command(path),NULL);
}
return 1;
}
@ -466,6 +466,9 @@ void on_save_done(main_window *widgets, config_str output, int size){
case 2:
yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
break;
case 3:
yon_ubl_status_box_render(SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
}
textdomain(LocaleName);
@ -526,7 +529,7 @@ void on_config_local_save(GtkWidget *, main_window *){
}
void on_config_custom_save(GtkWidget *, main_window *){
main_config.save_config=1;
main_config.save_config=3;
template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_command("system"),NULL);
if (window){
yon_hide_passwords(window);

@ -256,6 +256,8 @@ typedef struct{
GtkWidget *GroupsTree;
GtkWidget *GroupAddButton;
GtkWidget *GroupRemoveButton;
GtkListStore *UsersShutdownList;
GtkListStore *GroupsShutdownList;
const char *default_user_name;
const char *default_password;
@ -538,4 +540,8 @@ char *yon_char_parsed_to_string_include_empty(config_str parsed, int parsed_size
config_str yon_parameter_parse(char *parameter, int *size);
int yon_parameter_check_tag(char *tag,char *string);
config_str yon_parameter_get_by_template(char *parameter, char *pattern, int *size);
void on_additional_settings_group_sync_remove(GtkWidget *, ubl_settings_usergroups_additional_settings_window *window);
void on_additional_settings_group_sync_add(GtkWidget *, ubl_settings_usergroups_additional_settings_window *window);
void on_additional_settings_user_sync_remove(GtkWidget *, ubl_settings_usergroups_additional_settings_window *window);
void on_additional_settings_user_sync_add(GtkWidget *, ubl_settings_usergroups_additional_settings_window *window);
#endif

@ -1,4 +1,4 @@
PARAMETER:DESCRIPTION
PARAMETER:DESCRIPTION:PARAMETER_NAME
shutdown@all:When the system is shut down, synchronize all users in the system with the global configuration
shutdown@users:On system shutdown, synchronize users 1000<=UID<=6000 in the system with the global configuration
shutdown@systems:On system shutdown, synchronize system users 500<=UID<=999 in the system with the global configuration

1 PARAMETER:DESCRIPTION PARAMETER:DESCRIPTION:PARAMETER_NAME
2 shutdown@all:When the system is shut down, synchronize all users in the system with the global configuration shutdown@all:When the system is shut down, synchronize all users in the system with the global configuration
3 shutdown@users:On system shutdown, synchronize users 1000<=UID<=6000 in the system with the global configuration shutdown@users:On system shutdown, synchronize users 1000<=UID<=6000 in the system with the global configuration
4 shutdown@systems:On system shutdown, synchronize system users 500<=UID<=999 in the system with the global configuration shutdown@systems:On system shutdown, synchronize system users 500<=UID<=999 in the system with the global configuration

@ -1,17 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<!-- Generated with glade 3.40.0 -->
<interface domain="ubl-settings-usergroups">
<requires lib="gtk+" version="3.24"/>
<!-- interface-css-provider-path ubl-settings-usergroups.css -->
<object class="GtkListStore" id="GroupsShutdownList">
<columns>
<!-- column-name active -->
<column type="gboolean"/>
<!-- column-name RenderName -->
<column type="gchararray"/>
<!-- column-name ValueMin -->
<column type="gint"/>
<!-- column-name ValueMax -->
<column type="gint"/>
<!-- column-name Indeletable -->
<column type="gboolean"/>
<!-- column-name Sensitive -->
<column type="gboolean"/>
</columns>
<data>
<row>
<col id="0">True</col>
<col id="1" translatable="yes">All groups in system</col>
<col id="2">1</col>
<col id="3">65535</col>
<col id="4">True</col>
<col id="5">True</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">Groups</col>
<col id="2">1000</col>
<col id="3">6000</col>
<col id="4">True</col>
<col id="5">False</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">System groups</col>
<col id="2">500</col>
<col id="3">999</col>
<col id="4">True</col>
<col id="5">False</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">Group GID range</col>
<col id="2">0</col>
<col id="3">0</col>
<col id="4">True</col>
<col id="5">False</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">Group GID in system</col>
<col id="2">0</col>
<col id="3">0</col>
<col id="4">True</col>
<col id="5">False</col>
</row>
</data>
</object>
<object class="GtkListStore" id="UsersShutdownList">
<columns>
@ -20,10 +68,56 @@
<!-- column-name Target -->
<column type="gchararray"/>
<!-- column-name MinValue -->
<column type="gulong"/>
<column type="guint"/>
<!-- column-name MaxValue -->
<column type="gulong"/>
<column type="guint"/>
<!-- column-name Indeletable -->
<column type="gboolean"/>
<!-- column-name Sensitive -->
<column type="gboolean"/>
</columns>
<data>
<row>
<col id="0">True</col>
<col id="1" translatable="yes">All system users</col>
<col id="2">1</col>
<col id="3">65535</col>
<col id="4">True</col>
<col id="5">True</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">Users</col>
<col id="2">1000</col>
<col id="3">6000</col>
<col id="4">True</col>
<col id="5">False</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">System users</col>
<col id="2">500</col>
<col id="3">999</col>
<col id="4">True</col>
<col id="5">False</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">Users UID range</col>
<col id="2">0</col>
<col id="3">0</col>
<col id="4">True</col>
<col id="5">False</col>
</row>
<row>
<col id="0">False</col>
<col id="1" translatable="yes">User UID in system</col>
<col id="2">0</col>
<col id="3">0</col>
<col id="4">True</col>
<col id="5">False</col>
</row>
</data>
</object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
@ -512,10 +606,16 @@
<property name="can-focus">True</property>
<property name="model">UsersShutdownList</property>
<property name="enable-grid-lines">both</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
<child>
<object class="GtkTreeViewColumn">
<child>
<object class="GtkCellRendererToggle"/>
<object class="GtkCellRendererToggle" id="UserActiveCell"/>
<attributes>
<attribute name="active">0</attribute>
</attributes>
</child>
</object>
</child>
@ -524,14 +624,22 @@
<property name="title" translatable="yes">Syncronization type</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Minimal UID</property>
<property name="title" translatable="yes">Minimum UID</property>
<child>
<object class="GtkCellRendererText"/>
<object class="GtkCellRendererText" id="UserMinCell">
<property name="max-width-chars">5</property>
</object>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
@ -539,7 +647,12 @@
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Maximum UID</property>
<child>
<object class="GtkCellRendererText"/>
<object class="GtkCellRendererText" id="UserMaxCell">
<property name="max-width-chars">5</property>
</object>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child>
@ -601,7 +714,7 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
@ -714,35 +827,55 @@
<property name="can-focus">True</property>
<property name="model">GroupsShutdownList</property>
<property name="enable-grid-lines">both</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">column</property>
<object class="GtkTreeViewColumn" id="GroupActiveCell">
<child>
<object class="GtkCellRendererToggle"/>
<attributes>
<attribute name="active">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">column</property>
<property name="title" translatable="yes">Syncronization type</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">column</property>
<property name="title" translatable="yes">Minimum GID</property>
<child>
<object class="GtkCellRendererText"/>
<object class="GtkCellRendererText" id="GroupMinCell">
<property name="editable">True</property>
<property name="max-width-chars">5</property>
</object>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">column</property>
<property name="title" translatable="yes">Maximum GID</property>
<child>
<object class="GtkCellRendererText"/>
<object class="GtkCellRendererText" id="GroupMaxCell">
<property name="editable">True</property>
<property name="max-width-chars">5</property>
</object>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child>
@ -804,7 +937,7 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>

Loading…
Cancel
Save