1 #include "frmEditAccount.h"
3 frmEditAccount::frmEditAccount( wxWindow* parent )
5 frmEditAccountADT( parent )
7 btnDetect->Enable(false);
10 void frmEditAccount::DetectAddressBook( wxCommandEvent& event )
13 // TODO: Currently unimplemented.
17 void frmEditAccount::UpdateSettings( wxCommandEvent& event )
20 // Check if server address matches against the blacklist.
21 // Bring up warning message if it does.
23 if (CheckBlacklist(txtAddress->GetValue())){
25 int MessageBoxResult = wxMessageBox(_("The server with the address given does not support the CardDAV protocol properly and shouldn't be used.\n\nData loss is very likely.\n\nDo you still want to continue using this server?"), _("Server warning"), wxYES_NO, this);
27 if (MessageBoxResult == wxNO){
33 // Update the settings for the account.
36 bool ContinueAcc = TRUE;
39 // Look for the account
43 if (AccountName == AccName){
45 // Update the settings for the account.
47 cfgfile->RenameGroup(AccountName, txtAccountName->GetValue());
49 cfgfile->SetPath(txtAccountName->GetValue());
50 //txtAccountName->SetValue(AccountName);
52 cfgfile->DeleteEntry(wxT("address"), FALSE);
53 cfgfile->Write(wxT("address"), txtAddress->GetValue());
55 cfgfile->DeleteEntry(wxT("port"), FALSE);
56 cfgfile->Write(wxT("port"), txtPort->GetValue());
58 cfgfile->DeleteEntry(wxT("username"), FALSE);
59 cfgfile->Write(wxT("username"), txtUsername->GetValue());
61 cfgfile->DeleteEntry(wxT("password"), FALSE);
62 cfgfile->Write(wxT("password"), txtPassword->GetValue());
64 cfgfile->DeleteEntry(wxT("prefix"), FALSE);
65 cfgfile->Write(wxT("prefix"), txtPrefix->GetValue());
67 cfgfile->DeleteEntry(wxT("ssl"), FALSE);
69 if (chkSSL->GetValue() == TRUE){
71 cfgfile->Write(wxT("ssl"), wxT("true"));
75 cfgfile->Write(wxT("ssl"), wxT("false"));
79 cfgfile->DeleteEntry(wxT("refresh"), FALSE);
80 cfgfile->Write(wxT("refresh"), txtRefresh->GetValue());
86 cfgfile->SetPath(wxT("/"));
87 ContinueAcc = cfgfile->GetNextGroup(AccountName, itemindex);
91 // Set the dialog result to true and close the window.
98 void frmEditAccount::LoadSettings( wxString AccNameIn ){
100 // Get the data from the accounts settings file and
101 // fill in the account fields.
105 bool ContinueAcc = TRUE;
106 wxString AccountName;
107 wxString AccountData;
109 ContinueAcc = cfgfile->GetFirstGroup(AccountName, itemindex);
113 if (AccountName == AccName){
115 cfgfile->SetPath(AccountName);
116 txtAccountName->SetValue(AccountName);
118 cfgfile->Read("address", &AccountData);
119 txtAddress->SetValue(AccountData);
121 cfgfile->Read("port", &AccountData);
122 txtPort->SetValue(AccountData);
124 cfgfile->Read("username", &AccountData);
125 txtUsername->SetValue(AccountData);
127 cfgfile->Read("password", &AccountData);
128 txtPassword->SetValue(AccountData);
130 cfgfile->Read("prefix", &AccountData);
131 txtPrefix->SetValue(AccountData);
133 cfgfile->Read("ssl", &AccountData);
134 if (AccountData == wxT("true")){
136 chkSSL->SetValue(TRUE);
140 cfgfile->Read("refresh", &AccountData);
141 txtRefresh->SetValue(AccountData);
147 cfgfile->SetPath(wxT("/"));
148 ContinueAcc = cfgfile->GetNextGroup(AccountName, itemindex);
154 void frmEditAccount::CloseWindow( wxCommandEvent& event )
157 DialogResult = false;
162 bool frmEditAccount::GetDialogResult(){
164 // Get the result of the dialog.
170 void frmEditAccount::LoadPointers( wxFileConfig* cfgin ){
172 // Setup the account configuration file pointer.