Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
utf8: Implemented further UTF8 support
[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