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.