Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
cc88900d51612ed40c814d795b66f3c30b3f9444
[xestiacalendar/.git] / source / forms / editaccount / frmEditAccount.cpp
1 // frmEditAccount.cpp - frmEditAccount form functions.
2 //
3 // (c) 2016-2017 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar.
6 //
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.
10 //
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.
15 //
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 )
22 :
23 frmEditAccountADT( parent )
24 {
25         btnDetect->Enable(false);
26 }
28 void frmEditAccount::DetectAddressBook( wxCommandEvent& event )
29 {
31         // TODO: Currently unimplemented.
32         
33 }
35 void frmEditAccount::UpdateSettings( wxCommandEvent& event )
36 {
38         // Check if server address matches against the blacklist.
39         // Bring up warning message if it does.
40         
41         if (CheckBlacklist(txtAddress->GetValue())){
42                 
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);
44                 
45                 if (MessageBoxResult == wxNO){
46                         return;
47                 }
48                         
49         }
50         
51         // Update the settings for the account.
53         long itemindex = 0;
54         bool ContinueAcc = TRUE;
55         wxString AccountName;
57         // Look for the account
58         
59         while (ContinueAcc){
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);
69                         
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){
88                         
89                                 cfgfile->Write(wxT("ssl"), wxT("true"));
90                         
91                         } else {
92                         
93                                 cfgfile->Write(wxT("ssl"), wxT("false"));
94                         
95                         }
97                         cfgfile->DeleteEntry(wxT("refresh"), FALSE);
98                         cfgfile->Write(wxT("refresh"), txtRefresh->GetValue());
100                         break;
102                 }
103                 
104                 cfgfile->SetPath(wxT("/"));
105                 ContinueAcc = cfgfile->GetNextGroup(AccountName, itemindex);
107         }
109         // Set the dialog result to true and close the window.
110         
111         DialogResult = true;    
112         this->Close();
113         
116 void frmEditAccount::LoadSettings( wxString AccNameIn ){
118         // Get the data from the accounts settings file and
119         // fill in the account fields.
121         AccName = AccNameIn;
122         long itemindex = 0;
123         bool ContinueAcc = TRUE;
124         wxString AccountName;
125         wxString AccountData;
126         
127         ContinueAcc = cfgfile->GetFirstGroup(AccountName, itemindex);
128         
129         while (ContinueAcc){
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")){
153                         
154                                 chkSSL->SetValue(TRUE);
155                         
156                         }
157                         
158                         cfgfile->Read("refresh", &AccountData);
159                         txtRefresh->SetValue(AccountData);
160                         
161                         break;
163                 }
164                 
165                 cfgfile->SetPath(wxT("/"));
166                 ContinueAcc = cfgfile->GetNextGroup(AccountName, itemindex);
168         }
172 void frmEditAccount::CloseWindow( wxCommandEvent& event )
175         DialogResult = false;
176         this->Close();
177         
180 bool frmEditAccount::GetDialogResult(){
182         // Get the result of the dialog.
183         
184         return DialogResult;
185         
188 void frmEditAccount::LoadPointers( wxFileConfig* cfgin ){
190         // Setup the account configuration file pointer.
191         
192         cfgfile = cfgin;
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy