@ -8,10 +8,10 @@ int yon_load_proceed(YON_CONFIG_TYPE type){
yon_config_clean ( ) ;
yon_config_load_config ( YON_CONFIG_DEFAULT , config_get_default_command , NULL ) ;
if ( type = = YON_CONFIG_GLOBAL ) {
yon_config_load_config ( type , config_get_global_command , NULL ) ;
yon_config_load_config ( type , config_get_command ( " global " ) , NULL ) ;
}
if ( type = = YON_CONFIG_LOCAL ) {
yon_config_load_config ( type , config_get_local_command , NULL ) ;
yon_config_load_config ( type , config_get_command ( " global " ) , NULL ) ;
yon_config_load_config ( YON_CONFIG_GLOBAL , config_get_global_only_parameters , NULL ) ;
yon_config_set_status ( DEFAULTPASSWD_parameter , - 2 ) ;
yon_config_set_status ( DEFAULTROOTPASSWD_parameter , - 2 ) ;
@ -51,7 +51,21 @@ int yon_load_proceed(YON_CONFIG_TYPE type){
}
return 1 ;
}
else if ( type = = YON_CONFIG_CUSTOM ) {
char * path ;
GtkWidget * dialog = gtk_file_chooser_dialog_new ( template_app_information . app_title , NULL , GTK_FILE_CHOOSER_ACTION_SAVE , CANCEL_LABEL , GTK_RESPONSE_CANCEL , OPEN_LABEL , GTK_RESPONSE_ACCEPT , NULL ) ;
GtkFileFilter * filter = gtk_file_filter_new ( ) ;
gtk_file_filter_add_pattern ( filter , " *.ini " ) ;
gtk_file_chooser_add_filter ( GTK_FILE_CHOOSER ( dialog ) , filter ) ;
int response = gtk_dialog_run ( GTK_DIALOG ( dialog ) ) ;
if ( response = = GTK_RESPONSE_ACCEPT ) {
char * file = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER ( dialog ) ) ;
if ( ! yon_char_is_empty ( file ) ) {
path = file ;
}
} else return 0 ;
yon_config_load_config ( type , config_get_command ( path ) , NULL ) ;
}
}
@ -182,6 +196,15 @@ void on_config_global_load(GtkWidget *self, main_window *widgets){
main_config . load_mode = 0 ;
yon_interface_update ( widgets ) ;
}
void on_config_custom_load ( GtkWidget * self , main_window * widgets ) {
yon_load_proceed ( YON_CONFIG_GLOBAL ) ;
textdomain ( template_ui_LocaleName ) ;
yon_ubl_status_box_render ( GLOBAL_LOAD_SUCCESS_LABEL , BACKGROUND_IMAGE_SUCCESS_TYPE ) ;
textdomain ( LocaleName ) ;
main_config . load_mode = 0 ;
yon_interface_update ( widgets ) ;
}
void yon_samba_sync_proceed ( ) {
if ( main_config . sync_users ) {
@ -264,7 +287,7 @@ void yon_hide_passwords(template_saving_window *window){
newv = new_value ;
}
char * new_string = yon_char_unite ( ! yon_char_is_empty ( old ) ? old : " " , " \n " , ! yon_char_is_empty ( newv ) ? newv : " " , NULL ) ;
gtk_list_store_set ( window - > list , & iter , 7 , new_string , - 1 ) ;
gtk_list_store_set ( window - > list , & iter , 4 , new_string , - 1 ) ;
} else if ( strstr ( name , GROUPADD_SEARCH_macro ) ) {
char * old = NULL ;
@ -301,7 +324,7 @@ void yon_hide_passwords(template_saving_window *window){
newv = new_value ;
}
char * new_string = yon_char_unite ( ! yon_char_is_empty ( old ) ? old : " " , " \n " , ! yon_char_is_empty ( newv ) ? newv : " " , NULL ) ;
gtk_list_store_set ( window - > list , & iter , 7 , new_string , - 1 ) ;
gtk_list_store_set ( window - > list , & iter , 4 , new_string , - 1 ) ;
} else if ( strstr ( name , DEFAULTPASSWD_parameter ) ) {
@ -328,7 +351,7 @@ void yon_hide_passwords(template_saving_window *window){
}
}
char * new_string = yon_char_unite ( ! yon_char_is_empty ( old ) ? old : " " , " \n " , ! yon_char_is_empty ( newv ) ? newv : " " , NULL ) ;
gtk_list_store_set ( window - > list , & iter , 7 , new_string , - 1 ) ;
gtk_list_store_set ( window - > list , & iter , 4 , new_string , - 1 ) ;
} else if ( strstr ( name , DEFAULTROOTPASSWD_parameter ) ) {
char * old = NULL ;
@ -353,7 +376,7 @@ void yon_hide_passwords(template_saving_window *window){
}
}
char * new_string = yon_char_unite ( ! yon_char_is_empty ( old ) ? old : " " , " \n " , ! yon_char_is_empty ( newv ) ? newv : " " , NULL ) ;
gtk_list_store_set ( window - > list , & iter , 7 , new_string , - 1 ) ;
gtk_list_store_set ( window - > list , & iter , 4 , new_string , - 1 ) ;
}
}
@ -361,17 +384,22 @@ void yon_hide_passwords(template_saving_window *window){
void on_save_done ( main_window * widgets , config_str output , int size ) {
char * final_output = yon_char_parsed_to_string ( output , size , " " ) ;
printf ( " testove %s\n " , final_output ) ;
printf ( " %s\n " , final_output ) ;
free ( final_output ) ;
yon_char_parsed_free ( output , size ) ;
on_config_update ( NULL , widgets ) ;
if ( main_config . load_mode = = 1 ) {
yon_accept_changes ( ) ;
yon_samba_sync_proceed ( ) ;
}
}
void on_config_save ( GtkWidget * self , main_window * widgets ) {
yon_accept_changes ( ) ;
yon_samba_sync_proceed ( ) ;
template_saving_window * window = yon_save_proceed ( NULL , YON_CONFIG_BOTH , config_get_global_command , NULL ) ;
template_saving_window * window = yon_save_proceed ( NULL , YON_CONFIG_BOTH , config_get_command ( " global " ) , NULL ) ;
if ( window ) {
if ( main_config . load_mode = = 0 ) {
GtkTreeIter iter ;
@ -431,9 +459,7 @@ void on_config_save(GtkWidget *self, main_window *widgets){
}
void on_config_global_save ( GtkWidget * self , main_window * widgets ) {
yon_accept_changes ( ) ;
yon_samba_sync_proceed ( ) ;
template_saving_window * window = yon_save_proceed ( " global " , YON_CONFIG_GLOBAL , config_get_global_command , NULL ) ;
template_saving_window * window = yon_save_proceed ( " global " , YON_CONFIG_GLOBAL , config_get_command ( " global " ) , NULL ) ;
if ( window ) {
yon_hide_passwords ( window ) ;
}
@ -465,7 +491,7 @@ void on_config_local_save(GtkWidget *self, main_window *widgets){
yon_samba_sync_proceed ( ) ;
// char *output = yon_config_save_simple(YON_CONFIG_LOCAL,"system");
// if (output) puts(output);
template_saving_window * window = yon_save_proceed ( " system " , YON_CONFIG_LOCAL , config_get_local_command , NULL ) ;
template_saving_window * window = yon_save_proceed ( " system " , YON_CONFIG_LOCAL , config_get_command ( " system " ) , NULL ) ;
if ( window ) {
yon_hide_passwords ( window ) ;
g_signal_connect ( G_OBJECT ( window - > Window ) , " destroy " , G_CALLBACK ( on_save_window_close_update ) , widgets ) ;
@ -477,6 +503,13 @@ void on_config_local_save(GtkWidget *self, main_window *widgets){
}
}
void on_config_custom_save ( GtkWidget * self , main_window * widgets ) {
template_saving_window * window = yon_save_proceed ( NULL , YON_CONFIG_CUSTOM , config_get_command ( " system " ) , NULL ) ;
if ( window ) {
yon_hide_passwords ( window ) ;
}
}
void on_saving_settings_save ( GtkWidget * self , yon_savasettings_window * window ) {
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > SambaCheck ) ) ) {
if ( ! yon_config_append ( SAVE_ROOTCOPY_CHANGES_parameter , " /var/lib/samba " , " , " ) ) {
@ -1842,9 +1875,9 @@ void on_user_save(GtkWidget *self, dictionary *dict){
if ( deactivate ) {
if ( strlen ( password ) > 1 & & password [ 0 ] = = ' % ' & & password [ 1 ] = = ' % ' ) {
char * temp = yon_char_replace ( password , " %% " , " !! " ) ;
password = yon_char_replace ( temp , " !! " , " %%! * " ) ;
password = yon_char_replace ( temp , " !! " , " %%! " ) ;
} else {
password = yon_char_append ( " ! * " , password ) ;
password = yon_char_append ( " ! " , password ) ;
}
}
@ -2428,10 +2461,10 @@ void on_main_edit(GtkWidget *self, main_window *widgets){
free ( yon_char_divide ( window - > old_password , 1 ) ) ;
}
if ( strcmp ( parameters [ 5 ] , " x " ) & & strcmp ( parameters [ 5 ] , " " ) ) {
if ( strstr ( parameters [ 5 ] , " ! * " ) ) {
if ( strstr ( parameters [ 5 ] , " ! " ) ) {
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > userDeactivatedCheck ) , 1 ) ;
}
yon_char_divide ( strstr ( parameters [ 5 ] , " ! * " ) , 1 ) ;
yon_char_divide ( strstr ( parameters [ 5 ] , " ! " ) , 1 ) ;
if ( ! yon_char_is_empty ( parameters [ 5 ] ) ) {
gtk_entry_set_text ( GTK_ENTRY ( window - > userPasswordEntry ) , parameters [ 5 ] ) ;
gtk_combo_box_set_active ( GTK_COMBO_BOX ( window - > userPasswordCombo ) , 2 ) ;
@ -2745,9 +2778,11 @@ main_window *yon_main_window_complete(main_window *widgets){
g_signal_connect ( G_OBJECT ( widgets - > MainNotebook ) , " switch-page " , G_CALLBACK ( on_notebook_page_changed ) , widgets ) ;
g_signal_connect ( G_OBJECT ( widgets - > SaveGlobalMenuItem ) , " activate " , G_CALLBACK ( on_config_global_save ) , widgets ) ;
g_signal_connect ( G_OBJECT ( widgets - > SaveLocalMenuItem ) , " activate " , G_CALLBACK ( on_config_local_save ) , widgets ) ;
g_signal_connect ( G_OBJECT ( widgets - > SaveCustomMenuItem ) , " activate " , G_CALLBACK ( on_config_custom_save ) , widgets ) ;
g_signal_connect ( G_OBJECT ( widgets - > LoadGlobalMenuItem ) , " activate " , G_CALLBACK ( on_config_global_load ) , widgets ) ;
g_signal_connect ( G_OBJECT ( widgets - > LoadLocalMenuItem ) , " activate " , G_CALLBACK ( on_config_local_load ) , widgets ) ;
g_signal_connect ( G_OBJECT ( widgets - > LoadCustomMenuItem ) , " activate " , G_CALLBACK ( on_config_custom_load ) , widgets ) ;
yon_rmb_menu_setup ( widgets - > UsersTree , EDIT_LABEL , edit_icon_name , G_CALLBACK ( on_main_edit ) , widgets , REMOVE_LABEL , delete_icon_name , G_CALLBACK ( on_main_delete ) , widgets , NULL ) ;
yon_rmb_menu_setup ( widgets - > GroupsTree , EDIT_LABEL , edit_icon_name , G_CALLBACK ( on_main_edit ) , widgets , REMOVE_LABEL , delete_icon_name , G_CALLBACK ( on_main_delete ) , widgets , NULL ) ;