; =========================================================
; This file was generated by NSISDialogDesigner 1.6.0.0
; https://coolsoft.altervista.org/nsisdialogdesigner
;
; Do not edit it manually, use NSISDialogDesigner instead!
; =========================================================

; handle variables
Var hCtl_encryption
Var hCtl_encryption_EncryptionCheckBox
Var hCtl_encryption_EncryptionGroupBox
Var hCtl_encryption_ca_name_help
Var hCtl_encryption_ca_name_help_hImage
Var hCtl_encryption_ca_file_help
Var hCtl_encryption_ca_file_help_hImage
Var hCtl_encryption_certificate_file_help
Var hCtl_encryption_certificate_file_help_hImage
Var hCtl_encryption_private_key_file_help
Var hCtl_encryption_private_key_file_help_hImage
Var hCtl_encryption_ca_name
Var hCtl_encryption_label_ca_name
Var hCtl_encryption_ca_file_Txt
Var hCtl_encryption_ca_file_Btn
Var hCtl_encryption_certificate_file_Txt
Var hCtl_encryption_certificate_file_Btn
Var hCtl_encryption_label_ca_file
Var hCtl_encryption_private_key_file_Txt
Var hCtl_encryption_private_key_file_Btn
Var hCtl_encryption_label_certificate_file
Var hCtl_encryption_label_private_key_file


; dialog create function
Function fnc_encryption_Create
  
  ; === encryption (type: Dialog) ===
  nsDialogs::Create 1018
  Pop $hCtl_encryption
  ${If} $hCtl_encryption == error
    Abort
  ${EndIf}
  !insertmacro MUI_HEADER_TEXT "Centreon Monitoring Agent" "Encryption parameters"
  
  ; === EncryptionCheckBox (type: Checkbox) ===
  ${NSD_CreateCheckbox} 8u 2u 68u 15u "Encryption"
  Pop $hCtl_encryption_EncryptionCheckBox
  ${NSD_OnClick} $hCtl_encryption_EncryptionCheckBox on_encryptioncheckbox_click
  
  ; === EncryptionGroupBox (type: GroupBox) ===
  ${NSD_CreateGroupBox} 8u 20u 255u 84u "Certificates"
  Pop $hCtl_encryption_EncryptionGroupBox
  
  ; === ca_name_help (type: Bitmap) ===
  ${NSD_CreateBitmap} 246u 85u 12u 11u ""
  Pop $hCtl_encryption_ca_name_help
  ${NSD_OnClick} $hCtl_encryption_ca_name_help ca_name_help_onClick
  File "/oname=$PLUGINSDIR\info.bmp" "resources\info.bmp"
  ${NSD_SetImage} $hCtl_encryption_ca_name_help "$PLUGINSDIR\info.bmp" $hCtl_encryption_ca_name_help_hImage
  
  ; === ca_file_help (type: Bitmap) ===
  ${NSD_CreateBitmap} 246u 66u 12u 11u ""
  Pop $hCtl_encryption_ca_file_help
  ${NSD_OnClick} $hCtl_encryption_ca_file_help ca_file_help_onClick
  File "/oname=$PLUGINSDIR\info.bmp" "resources\info.bmp"
  ${NSD_SetImage} $hCtl_encryption_ca_file_help "$PLUGINSDIR\info.bmp" $hCtl_encryption_ca_file_help_hImage
  
  ; === certificate_file_help (type: Bitmap) ===
  ${NSD_CreateBitmap} 246u 47u 12u 11u ""
  Pop $hCtl_encryption_certificate_file_help
  ${NSD_OnClick} $hCtl_encryption_certificate_file_help certificate_file_help_onClick
  File "/oname=$PLUGINSDIR\info.bmp" "resources\info.bmp"
  ${NSD_SetImage} $hCtl_encryption_certificate_file_help "$PLUGINSDIR\info.bmp" $hCtl_encryption_certificate_file_help_hImage
  
  ; === private_key_file_help (type: Bitmap) ===
  ${NSD_CreateBitmap} 246u 29u 12u 11u ""
  Pop $hCtl_encryption_private_key_file_help
  ${NSD_OnClick} $hCtl_encryption_private_key_file_help private_key_file_help_onClick
  File "/oname=$PLUGINSDIR\info.bmp" "resources\info.bmp"
  ${NSD_SetImage} $hCtl_encryption_private_key_file_help "$PLUGINSDIR\info.bmp" $hCtl_encryption_private_key_file_help_hImage
  
  ; === ca_name (type: Text) ===
  ${NSD_CreateText} 115u 84u 127u 12u ""
  Pop $hCtl_encryption_ca_name
  
  ; === label_ca_name (type: Label) ===
  ${NSD_CreateLabel} 12u 86u 92u 10u "Certificate Common Name"
  Pop $hCtl_encryption_label_ca_name
  
  ; === ca_file_Txt (type: Text) ===
  ${NSD_CreateText} 115u 65u 106u 12u ""
  Pop $hCtl_encryption_ca_file_Txt
  
  ; === ca_file_Btn (type: Button) ===
  ${NSD_CreateButton} 222u 65u 20u 12u "..."
  Pop $hCtl_encryption_ca_file_Btn
  ${NSD_OnClick} $hCtl_encryption_ca_file_Btn fnc_hCtl_encryption_ca_file_Click
  
  ; === certificate_file_Txt (type: Text) ===
  ${NSD_CreateText} 115u 46u 106u 12u ""
  Pop $hCtl_encryption_certificate_file_Txt
  
  ; === certificate_file_Btn (type: Button) ===
  ${NSD_CreateButton} 222u 46u 20u 12u "..."
  Pop $hCtl_encryption_certificate_file_Btn
  ${NSD_OnClick} $hCtl_encryption_certificate_file_Btn fnc_hCtl_encryption_certificate_file_Click
  
  ; === label_ca_file (type: Label) ===
  ${NSD_CreateLabel} 12u 67u 99u 10u "Trusted CA's certificate file:"
  Pop $hCtl_encryption_label_ca_file
  
  ; === private_key_file_Txt (type: Text) ===
  ${NSD_CreateText} 115u 28u 106u 12u ""
  Pop $hCtl_encryption_private_key_file_Txt
  
  ; === private_key_file_Btn (type: Button) ===
  ${NSD_CreateButton} 222u 28u 20u 12u "..."
  Pop $hCtl_encryption_private_key_file_Btn
  ${NSD_OnClick} $hCtl_encryption_private_key_file_Btn fnc_hCtl_encryption_private_key_file_Click
  
  ; === label_certificate_file (type: Label) ===
  ${NSD_CreateLabel} 12u 49u 66u 10u "Certificate file:"
  Pop $hCtl_encryption_label_certificate_file
  
  ; === label_private_key_file (type: Label) ===
  ${NSD_CreateLabel} 12u 30u 66u 10u "Private key file:"
  Pop $hCtl_encryption_label_private_key_file
  
  ; CreateFunctionCustomScript
  Call init_encryption_dlg
  Call on_encryptioncheckbox_click
  
  
FunctionEnd

; dialog show function
Function fnc_encryption_Show
  Call fnc_encryption_Create
  nsDialogs::Show
FunctionEnd


; onClick handler for FileRequest Button $hCtl_encryption_ca_file_Btn
Function fnc_hCtl_encryption_ca_file_Click
	Pop $R0
	${If} $R0 == $hCtl_encryption_ca_file_Btn
		${NSD_GetText} $hCtl_encryption_ca_file_Txt $R0
		nsDialogs::SelectFileDialog open "$R0" "*.crt files|*.crt"
		Pop $R0
		${If} "$R0" != ""
			${NSD_SetText} $hCtl_encryption_ca_file_Txt "$R0"
		${EndIf}
	${EndIf}
FunctionEnd

; onClick handler for FileRequest Button $hCtl_encryption_certificate_file_Btn
Function fnc_hCtl_encryption_certificate_file_Click
	Pop $R0
	${If} $R0 == $hCtl_encryption_certificate_file_Btn
		${NSD_GetText} $hCtl_encryption_certificate_file_Txt $R0
		nsDialogs::SelectFileDialog open "$R0" "*.key files|*.key"
		Pop $R0
		${If} "$R0" != ""
			${NSD_SetText} $hCtl_encryption_certificate_file_Txt "$R0"
		${EndIf}
	${EndIf}
FunctionEnd

; onClick handler for FileRequest Button $hCtl_encryption_private_key_file_Btn
Function fnc_hCtl_encryption_private_key_file_Click
	Pop $R0
	${If} $R0 == $hCtl_encryption_private_key_file_Btn
		${NSD_GetText} $hCtl_encryption_private_key_file_Txt $R0
		nsDialogs::SelectFileDialog open "$R0" "*.crt files|*.crt"
		Pop $R0
		${If} "$R0" != ""
			${NSD_SetText} $hCtl_encryption_private_key_file_Txt "$R0"
		${EndIf}
	${EndIf}
FunctionEnd
