|
|
|
@ -406,6 +406,157 @@ void on_file_amount_checked(GtkToggleButton *self, logrotate_configure_window *w
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void on_rules_accept(GtkWidget *self, dictionary *dict){
|
|
|
|
|
|
|
|
GtkEntry *entry = yon_dictionary_get_data(dict->first,GtkEntry*);
|
|
|
|
|
|
|
|
logrotate_rules_window *window = yon_dictionary_get_data(dict->first->next,logrotate_rules_window*);
|
|
|
|
|
|
|
|
int owner_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserReadCheck));
|
|
|
|
|
|
|
|
int owner_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserWriteCheck));
|
|
|
|
|
|
|
|
int owner_exec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserExecuteCheck));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int group_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupReadCheck));
|
|
|
|
|
|
|
|
int group_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupWriteCheck));
|
|
|
|
|
|
|
|
int group_exec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupExecuteCheck));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int public_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PublicReadCheck));
|
|
|
|
|
|
|
|
int public_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PublicWriteCheck));
|
|
|
|
|
|
|
|
int public_exec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PublicExecuteCheck));
|
|
|
|
|
|
|
|
int owner = owner_read&&owner_write&&owner_exec? 7 : \
|
|
|
|
|
|
|
|
owner_read&&!owner_write&&!owner_exec ? 4 : \
|
|
|
|
|
|
|
|
!owner_read&&owner_write&&!owner_exec ? 2 : \
|
|
|
|
|
|
|
|
!owner_read&&!owner_write&&owner_exec ? 1 : \
|
|
|
|
|
|
|
|
owner_read&&owner_write&&!owner_exec ? 6 : \
|
|
|
|
|
|
|
|
owner_read&&!owner_write&&owner_exec ? 5 : \
|
|
|
|
|
|
|
|
!owner_read&&owner_write&&owner_exec ? 3 : \
|
|
|
|
|
|
|
|
0;
|
|
|
|
|
|
|
|
int group = group_read&&group_write&&group_exec? 7 : \
|
|
|
|
|
|
|
|
group_read&&!group_write&&!group_exec ? 4 : \
|
|
|
|
|
|
|
|
!group_read&&group_write&&!group_exec ? 2 : \
|
|
|
|
|
|
|
|
!group_read&&!group_write&&group_exec ? 1 : \
|
|
|
|
|
|
|
|
group_read&&group_write&&!group_exec ? 6 : \
|
|
|
|
|
|
|
|
group_read&&!group_write&&group_exec ? 5 : \
|
|
|
|
|
|
|
|
!group_read&&group_write&&group_exec ? 3 : \
|
|
|
|
|
|
|
|
0;
|
|
|
|
|
|
|
|
int public = public_read&&public_write&&public_exec? 7 : \
|
|
|
|
|
|
|
|
public_read&&!public_write&&!public_exec ? 4 : \
|
|
|
|
|
|
|
|
!public_read&&public_write&&!public_exec ? 2 : \
|
|
|
|
|
|
|
|
!public_read&&!public_write&&public_exec ? 1 : \
|
|
|
|
|
|
|
|
public_read&&public_write&&!public_exec ? 6 : \
|
|
|
|
|
|
|
|
public_read&&!public_write&&public_exec ? 5 : \
|
|
|
|
|
|
|
|
!public_read&&public_write&&public_exec ? 3 : \
|
|
|
|
|
|
|
|
0;
|
|
|
|
|
|
|
|
gtk_entry_set_text(entry,yon_char_unite(yon_char_from_int(owner),yon_char_from_int(group),yon_char_from_int(public),NULL));
|
|
|
|
|
|
|
|
gtk_widget_destroy(window->Window);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void on_rules_update(GtkWidget *self, logrotate_rules_window *window){
|
|
|
|
|
|
|
|
int owner_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserReadCheck));
|
|
|
|
|
|
|
|
int owner_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserWriteCheck));
|
|
|
|
|
|
|
|
int owner_exec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->UserExecuteCheck));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int group_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupReadCheck));
|
|
|
|
|
|
|
|
int group_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupWriteCheck));
|
|
|
|
|
|
|
|
int group_exec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->GroupExecuteCheck));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int public_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PublicReadCheck));
|
|
|
|
|
|
|
|
int public_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PublicWriteCheck));
|
|
|
|
|
|
|
|
int public_exec = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->PublicExecuteCheck));
|
|
|
|
|
|
|
|
int owner = owner_read&&owner_write&&owner_exec? 7 : \
|
|
|
|
|
|
|
|
owner_read&&!owner_write&&!owner_exec ? 4 : \
|
|
|
|
|
|
|
|
!owner_read&&owner_write&&!owner_exec ? 2 : \
|
|
|
|
|
|
|
|
!owner_read&&!owner_write&&owner_exec ? 1 : \
|
|
|
|
|
|
|
|
owner_read&&owner_write&&!owner_exec ? 6 : \
|
|
|
|
|
|
|
|
owner_read&&!owner_write&&owner_exec ? 5 : \
|
|
|
|
|
|
|
|
!owner_read&&owner_write&&owner_exec ? 3 : \
|
|
|
|
|
|
|
|
0;
|
|
|
|
|
|
|
|
int group = group_read&&group_write&&group_exec? 7 : \
|
|
|
|
|
|
|
|
group_read&&!group_write&&!group_exec ? 4 : \
|
|
|
|
|
|
|
|
!group_read&&group_write&&!group_exec ? 2 : \
|
|
|
|
|
|
|
|
!group_read&&!group_write&&group_exec ? 1 : \
|
|
|
|
|
|
|
|
group_read&&group_write&&!group_exec ? 6 : \
|
|
|
|
|
|
|
|
group_read&&!group_write&&group_exec ? 5 : \
|
|
|
|
|
|
|
|
!group_read&&group_write&&group_exec ? 3 : \
|
|
|
|
|
|
|
|
0;
|
|
|
|
|
|
|
|
int public = public_read&&public_write&&public_exec? 7 : \
|
|
|
|
|
|
|
|
public_read&&!public_write&&!public_exec ? 4 : \
|
|
|
|
|
|
|
|
!public_read&&public_write&&!public_exec ? 2 : \
|
|
|
|
|
|
|
|
!public_read&&!public_write&&public_exec ? 1 : \
|
|
|
|
|
|
|
|
public_read&&public_write&&!public_exec ? 6 : \
|
|
|
|
|
|
|
|
public_read&&!public_write&&public_exec ? 5 : \
|
|
|
|
|
|
|
|
!public_read&&public_write&&public_exec ? 3 : \
|
|
|
|
|
|
|
|
0;
|
|
|
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(window->FinalEntry),yon_char_unite(yon_char_from_int(owner),yon_char_from_int(group),yon_char_from_int(public),NULL));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void on_rules_open(GtkWidget *self,GtkEntry *entry){
|
|
|
|
|
|
|
|
GtkBuilder *builder = gtk_builder_new_from_resource(glade_rules_path);
|
|
|
|
|
|
|
|
logrotate_rules_window *window = malloc(sizeof(logrotate_rules_window));
|
|
|
|
|
|
|
|
window->Window=yon_gtk_builder_get_widget(builder,"MainWindow");
|
|
|
|
|
|
|
|
window->UserReadCheck=yon_gtk_builder_get_widget(builder,"UserReadCheck");
|
|
|
|
|
|
|
|
window->UserWriteCheck=yon_gtk_builder_get_widget(builder,"UserWriteCheck");
|
|
|
|
|
|
|
|
window->UserExecuteCheck=yon_gtk_builder_get_widget(builder,"UserExecuteCheck");
|
|
|
|
|
|
|
|
window->GroupReadCheck=yon_gtk_builder_get_widget(builder,"GroupReadCheck");
|
|
|
|
|
|
|
|
window->GroupWriteCheck=yon_gtk_builder_get_widget(builder,"GroupWriteCheck");
|
|
|
|
|
|
|
|
window->GroupExecuteCheck=yon_gtk_builder_get_widget(builder,"GroupExecuteCheck");
|
|
|
|
|
|
|
|
window->PublicReadCheck=yon_gtk_builder_get_widget(builder,"PublicReadCheck");
|
|
|
|
|
|
|
|
window->PublicWriteCheck=yon_gtk_builder_get_widget(builder,"PublicWriteCheck");
|
|
|
|
|
|
|
|
window->PublicExecuteCheck=yon_gtk_builder_get_widget(builder,"PublicExecuteCheck");
|
|
|
|
|
|
|
|
window->FinalEntry=yon_gtk_builder_get_widget(builder,"FinalEntry");
|
|
|
|
|
|
|
|
window->CancelButton=yon_gtk_builder_get_widget(builder,"CancelButton");
|
|
|
|
|
|
|
|
window->SaveButton=yon_gtk_builder_get_widget(builder,"SaveButton");
|
|
|
|
|
|
|
|
gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL);
|
|
|
|
|
|
|
|
dictionary *dict = NULL;
|
|
|
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(dict,"entry",entry);
|
|
|
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_rules_accept),dict);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->UserReadCheck),"toggled",G_CALLBACK(on_rules_update),window);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->UserWriteCheck),"toggled",G_CALLBACK(on_rules_update),window);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->UserExecuteCheck),"toggled",G_CALLBACK(on_rules_update),window);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->GroupReadCheck),"toggled",G_CALLBACK(on_rules_update),window);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->GroupWriteCheck),"toggled",G_CALLBACK(on_rules_update),window);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->GroupExecuteCheck),"toggled",G_CALLBACK(on_rules_update),window);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->PublicReadCheck),"toggled",G_CALLBACK(on_rules_update),window);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->PublicWriteCheck),"toggled",G_CALLBACK(on_rules_update),window);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->PublicExecuteCheck),"toggled",G_CALLBACK(on_rules_update),window);
|
|
|
|
|
|
|
|
gtk_widget_show(window->Window);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void on_filechooser_mode_switch(GtkWidget *self, logrotate_filechooser_window *window){
|
|
|
|
|
|
|
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->FileOrDirCheck))){
|
|
|
|
|
|
|
|
gtk_file_chooser_set_action(GTK_FILE_CHOOSER(window->FileChooser),GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_file_chooser_set_action(GTK_FILE_CHOOSER(window->FileChooser),GTK_FILE_CHOOSER_ACTION_OPEN);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void on_filechooser_save(GtkWidget *self, dictionary *dict){
|
|
|
|
|
|
|
|
logrotate_configure_window *window = yon_dictionary_get_data(dict->first,logrotate_configure_window*);
|
|
|
|
|
|
|
|
logrotate_filechooser_window *dialog = yon_dictionary_get_data(dict->first->next,logrotate_filechooser_window*);
|
|
|
|
|
|
|
|
char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->FileChooser));
|
|
|
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(window->FileAmountEntry),filename);
|
|
|
|
|
|
|
|
gtk_widget_destroy(dialog->FileChooser);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void on_filechooser_open(GtkWidget *self, logrotate_configure_window *window){
|
|
|
|
|
|
|
|
GtkBuilder *builder = gtk_builder_new_from_resource(glade_filechooser_path);
|
|
|
|
|
|
|
|
logrotate_filechooser_window *dialog = malloc(sizeof(logrotate_filechooser_window));
|
|
|
|
|
|
|
|
dialog->FileChooser = yon_gtk_builder_get_widget(builder,"FileChooser");
|
|
|
|
|
|
|
|
dialog->FileOrDirCheck = yon_gtk_builder_get_widget(builder,"FileOrDirCheck");
|
|
|
|
|
|
|
|
dialog->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton");
|
|
|
|
|
|
|
|
dialog->AcceptButton = yon_gtk_builder_get_widget(builder,"AcceptButton");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dictionary *dict = NULL;
|
|
|
|
|
|
|
|
gtk_window_set_title(GTK_WINDOW(dialog->FileChooser),TITLE_LABEL);
|
|
|
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window);
|
|
|
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(dict,"dialog",dialog);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(dialog->FileOrDirCheck),"toggled",G_CALLBACK(on_filechooser_mode_switch),dialog);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(dialog->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(dialog->AcceptButton),"clicked",G_CALLBACK(on_filechooser_save),dict);
|
|
|
|
|
|
|
|
gtk_widget_show(dialog->FileChooser);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_logrotate_save(GtkWidget *self, dictionary *dict){
|
|
|
|
void on_logrotate_save(GtkWidget *self, dictionary *dict){
|
|
|
|
logrotate_window *dialog = yon_dictionary_get_data(dict->first,logrotate_window*);
|
|
|
|
logrotate_window *dialog = yon_dictionary_get_data(dict->first,logrotate_window*);
|
|
|
|
logrotate_configure_window *window = yon_dictionary_get_data(dict->first->next,logrotate_configure_window*);
|
|
|
|
logrotate_configure_window *window = yon_dictionary_get_data(dict->first->next,logrotate_configure_window*);
|
|
|
|
@ -753,6 +904,11 @@ logrotate_configure_window *yon_logrotate_window_new(char *paths, logrotate_wind
|
|
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->EmailCombo),"changed",G_CALLBACK(on_combo_activate_first),window->EmailEntry);
|
|
|
|
g_signal_connect(G_OBJECT(window->EmailCombo),"changed",G_CALLBACK(on_combo_activate_first),window->EmailEntry);
|
|
|
|
g_signal_connect(G_OBJECT(window->EmailCombo),"changed",G_CALLBACK(on_combo_activate_first),window->EmailContentsCombo);
|
|
|
|
g_signal_connect(G_OBJECT(window->EmailCombo),"changed",G_CALLBACK(on_combo_activate_first),window->EmailContentsCombo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->FileAmountButton),"clicked",G_CALLBACK(on_filechooser_open),window);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->CreateLogButton),"clicked",G_CALLBACK(on_rules_open),window->CreateLogEntry);
|
|
|
|
|
|
|
|
|
|
|
|
int usize=0;
|
|
|
|
int usize=0;
|
|
|
|
config_str users = yon_ubl_get_all_users(&usize);
|
|
|
|
config_str users = yon_ubl_get_all_users(&usize);
|
|
|
|
yon_gtk_combo_box_fill(window->CreateLogUserCombo,users,usize);
|
|
|
|
yon_gtk_combo_box_fill(window->CreateLogUserCombo,users,usize);
|
|
|
|
|