1 // frmEditAccount.cpp - frmEditAccount form functions.
3 // (c) 2016-2017 Xestia Software Development.
5 // This file is part of Xestia Calendar.
7 // Xestia Calendar is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Calendar is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
19 #include "frmEditAccount.h"
21 frmEditAccount::frmEditAccount( wxWindow* parent )
23 frmEditAccountADT( parent )
25 btnDetect->Enable(false);
28 void frmEditAccount::DetectAddressBook( wxCommandEvent& event )
31 // TODO: Currently unimplemented.
35 void frmEditAccount::UpdateSettings( wxCommandEvent& event )
38 // Check if server address matches against the blacklist.
39 // Bring up warning message if it does.
41 if (CheckBlacklist(txtAddress->GetValue())){
43 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);
45 if (MessageBoxResult == wxNO){
51 // Update the settings for the account.
54 bool ContinueAcc = TRUE;
57 // Look for the account
61 if (AccountName == AccName){
63 // Update the settings for the account.
65 cfgfile->RenameGroup(AccountName, txtAccountName->GetValue());
67 cfgfile->SetPath(txtAccountName->GetValue());
68 //txtAccountName->SetValue(AccountName);
70 cfgfile->DeleteEntry(wxT("address"), FALSE);
71 cfgfile->Write(wxT("address"), txtAddress->GetValue());
73 cfgfile->DeleteEntry(wxT("port"), FALSE);
74 cfgfile->Write(wxT("port"), txtPort->GetValue());
76 cfgfile->DeleteEntry(wxT("username"), FALSE);
77 cfgfile->Write(wxT("username"), txtUsername->GetValue());
79 cfgfile->DeleteEntry(wxT("password"), FALSE);
80 cfgfile->Write(wxT("password"), txtPassword->GetValue());
82 cfgfile->DeleteEntry(wxT("prefix"), FALSE);
83 cfgfile->Write(wxT("prefix"), txtPrefix->GetValue());
85 cfgfile->DeleteEntry(wxT("ssl"), FALSE);
87 if (chkSSL->GetValue() == TRUE){
89 cfgfile->Write(wxT("ssl"), wxT("true"));
93 cfgfile->Write(wxT("ssl"), wxT("false"));
97 cfgfile->DeleteEntry(wxT("refresh"), FALSE);
98 cfgfile->Write(wxT("refresh"), txtRefresh->GetValue());
104 cfgfile->SetPath(wxT("/"));
105 ContinueAcc = cfgfile->GetNextGroup(AccountName, itemindex);
109 // Set the dialog result to true and close the window.
116 void frmEditAccount::LoadSettings( wxString AccNameIn ){
118 // Get the data from the accounts settings file and
119 // fill in the account fields.
123 bool ContinueAcc = TRUE;
124 wxString AccountName;
125 wxString AccountData;
127 ContinueAcc = cfgfile->GetFirstGroup(AccountName, itemindex);
131 if (AccountName == AccName){
133 cfgfile->SetPath(AccountName);
134 txtAccountName->SetValue(AccountName);
136 cfgfile->Read("address", &AccountData);
137 txtAddress->SetValue(AccountData);
139 cfgfile->Read("port", &AccountData);
140 txtPort->SetValue(AccountData);
142 cfgfile->Read("username", &AccountData);
143 txtUsername->SetValue(AccountData);
145 cfgfile->Read("password", &AccountData);
146 txtPassword->SetValue(AccountData);
148 cfgfile->Read("prefix", &AccountData);
149 txtPrefix->SetValue(AccountData);
151 cfgfile->Read("ssl", &AccountData);
152 if (AccountData == wxT("true")){
154 chkSSL->SetValue(TRUE);
158 cfgfile->Read("refresh", &AccountData);
159 txtRefresh->SetValue(AccountData);
165 cfgfile->SetPath(wxT("/"));
166 ContinueAcc = cfgfile->GetNextGroup(AccountName, itemindex);
172 void frmEditAccount::CloseWindow( wxCommandEvent& event )
175 DialogResult = false;
180 bool frmEditAccount::GetDialogResult(){
182 // Get the result of the dialog.
188 void frmEditAccount::LoadPointers( wxFileConfig* cfgin ){
190 // Setup the account configuration file pointer.