diff --git a/source/ubl-settings-update.c b/source/ubl-settings-update.c index 27a1c6b..f244902 100644 --- a/source/ubl-settings-update.c +++ b/source/ubl-settings-update.c @@ -1390,54 +1390,106 @@ void on_password_accept(GtkWidget *,dictionary *dict){ password_window *window = yon_dictionary_get_data(dict->first,password_window*); GtkWidget *target = yon_dictionary_get_data(dict->first->next,GtkWidget*); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->NoEncriptionCheck))){ - char *encryption = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->EncryptionCombo)); - char *hash = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordHashEntry)); - if (yon_char_is_empty(hash)){ - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); - yon_ubl_status_highlight_incorrect(window->PasswordHashEntry); - return; - } - char *temp = yon_char_unite(encryption,"|",hash,NULL); - gtk_entry_set_text(GTK_ENTRY(target),temp); - free(temp); - } else { - char *password = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); - char *password_check = (char*)gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry)); + int encription_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->EncryptionCombo)); + const char *encription = gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->EncryptionCombo)); + if (encription_active == 0){ + const char *password = gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); + const char *password_repeat = gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry)); if (strpbrk(password,"!@#%^&*\'")){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),PASSWORD_RESTRICTED_SYMBOL_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_highlight_incorrect(window->PasswordEntry); return; } - if (strcmp(password,password_check)){ + if (strcmp(password,password_repeat)){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),PASSWORD_MISMATCH_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_highlight_incorrect(window->PasswordEntry); yon_ubl_status_highlight_incorrect(window->RepeatPasswordEntry); return; } - char *encryption = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->EncryptionCombo)); - if (yon_char_is_empty(encryption)){ - gtk_entry_set_text(GTK_ENTRY(target),password); - + gtk_entry_set_text(GTK_ENTRY(target),password); + } else { + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->NoEncriptionCheck))){ + const char *hash = gtk_entry_get_text(GTK_ENTRY(window->PasswordHashEntry)); + if (!yon_char_is_empty(hash)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->PasswordHashEntry); + } + char *final = yon_char_unite(encription,"|",hash,NULL); + gtk_entry_set_text(GTK_ENTRY(target),final); + free(final); } else { - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->NoEncriptionCheck))){ - char *temp = yon_char_unite(encryption,"|",password,NULL); - gtk_entry_set_text(GTK_ENTRY(target),temp); - free(temp); - } else { - int size; - config_str hash = yon_config_load(yon_debug_output("%s\n",!strcmp(encryption,"sha512")?sha512_encrypt_command(password):sha256_encrypt_command(password)),&size); - yon_char_remove_last_symbol(hash[0],'\n'); - char *temp = yon_char_unite(encryption,"|",hash[0],NULL); - gtk_entry_set_text(GTK_ENTRY(target),temp); - yon_char_parsed_free(hash,size); - free(temp); + const char *password = gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); + const char *password_repeat = gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry)); + if (strpbrk(password,"!@#%^&*\'")){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),PASSWORD_RESTRICTED_SYMBOL_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->PasswordEntry); + return; } - } + if (strcmp(password,password_repeat)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),PASSWORD_MISMATCH_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->PasswordEntry); + yon_ubl_status_highlight_incorrect(window->RepeatPasswordEntry); + return; + } + + int size; + config_str hash = yon_config_load(yon_debug_output("%s\n",encription_active==1?sha512_encrypt_command(password):sha256_encrypt_command(password)),&size); + yon_char_remove_last_symbol(hash[0],'\n'); + char *final = yon_char_unite(encription,"|",hash[0],NULL); + gtk_entry_set_text(GTK_ENTRY(target),final); + free(final); + } } gtk_widget_destroy(window->Window); + // if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->NoEncriptionCheck))){ + // char *encryption = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->EncryptionCombo)); + // char *hash = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordHashEntry)); + // if (yon_char_is_empty(hash)){ + // yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + // yon_ubl_status_highlight_incorrect(window->PasswordHashEntry); + // return; + // } + // char *temp = yon_char_unite(encryption,"|",hash,NULL); + // gtk_entry_set_text(GTK_ENTRY(target),temp); + // free(temp); + // } else { + // char *password = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); + // char *password_check = (char*)gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry)); + // if (strpbrk(password,"!@#%^&*\'")){ + // yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),PASSWORD_RESTRICTED_SYMBOL_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + // yon_ubl_status_highlight_incorrect(window->PasswordEntry); + // return; + // } + // if (strcmp(password,password_check)){ + // yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),PASSWORD_MISMATCH_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + // yon_ubl_status_highlight_incorrect(window->PasswordEntry); + // yon_ubl_status_highlight_incorrect(window->RepeatPasswordEntry); + // return; + // } + // char *encryption = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->EncryptionCombo)); + // if (yon_char_is_empty(encryption)){ + // gtk_entry_set_text(GTK_ENTRY(target),password); + + // } else { + // if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->NoEncriptionCheck))){ + // char *temp = yon_char_unite(encryption,"|",password,NULL); + // gtk_entry_set_text(GTK_ENTRY(target),temp); + // free(temp); + // } else { + // int size; + // config_str hash = yon_config_load(yon_debug_output("%s\n",!strcmp(encryption,"sha512")?sha512_encrypt_command(password):sha256_encrypt_command(password)),&size); + // yon_char_remove_last_symbol(hash[0],'\n'); + // char *temp = yon_char_unite(encryption,"|",hash[0],NULL); + // gtk_entry_set_text(GTK_ENTRY(target),temp); + // yon_char_parsed_free(hash,size); + // free(temp); + // } + // } + + // } + } void on_mirror_path_removed(GtkWidget *self, mirror_add_window *window){