Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmEditAccount: Implemented code from Xestia Address Book
[xestiacalendar/.git] / source / forms / editaccount / frmEditAccount.cpp
1 #include "frmEditAccount.h"
3 frmEditAccount::frmEditAccount( wxWindow* parent )
4 :
5 frmEditAccountADT( parent )
6 {
7         btnDetect->Enable(false);
8 }
10 void frmEditAccount::DetectAddressBook( wxCommandEvent& event )
11 {
13         // TODO: Currently unimplemented.
14         
15 }
17 void frmEditAccount::UpdateSettings( wxCommandEvent& event )
18 {
20         // Check if server address matches against the blacklist.
21         // Bring up warning message if it does.
22         
23         if (CheckBlacklist(txtAddress->GetValue())){
24                 
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);
26                 
27                 if (MessageBoxResult == wxNO){
28                         return;
29                 }
30                         
31         }
32         
33         // Update the settings for the account.
35         long itemindex = 0;
36         bool ContinueAcc = TRUE;
37         wxString AccountName;
39         // Look for the account
40         
41         while (ContinueAcc){
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);
51                         
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){
70                         
71                                 cfgfile->Write(wxT("ssl"), wxT("true"));
72                         
73                         } else {
74                         
75                                 cfgfile->Write(wxT("ssl"), wxT("false"));
76                         
77                         }
79                         cfgfile->DeleteEntry(wxT("refresh"), FALSE);
80                         cfgfile->Write(wxT("refresh"), txtRefresh->GetValue());
82                         break;
84                 }
85                 
86                 cfgfile->SetPath(wxT("/"));
87                 ContinueAcc = cfgfile->GetNextGroup(AccountName, itemindex);
89         }
91         // Set the dialog result to true and close the window.
92         
93         DialogResult = true;    
94         this->Close();
95         
96 }
98 void frmEditAccount::LoadSettings( wxString AccNameIn ){
100         // Get the data from the accounts settings file and
101         // fill in the account fields.
103         AccName = AccNameIn;
104         long itemindex = 0;
105         bool ContinueAcc = TRUE;
106         wxString AccountName;
107         wxString AccountData;
108         
109         ContinueAcc = cfgfile->GetFirstGroup(AccountName, itemindex);
110         
111         while (ContinueAcc){
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")){
135                         
136                                 chkSSL->SetValue(TRUE);
137                         
138                         }
139                         
140                         cfgfile->Read("refresh", &AccountData);
141                         txtRefresh->SetValue(AccountData);
142                         
143                         break;
145                 }
146                 
147                 cfgfile->SetPath(wxT("/"));
148                 ContinueAcc = cfgfile->GetNextGroup(AccountName, itemindex);
150         }
154 void frmEditAccount::CloseWindow( wxCommandEvent& event )
157         DialogResult = false;
158         this->Close();
159         
162 bool frmEditAccount::GetDialogResult(){
164         // Get the result of the dialog.
165         
166         return DialogResult;
167         
170 void frmEditAccount::LoadPointers( wxFileConfig* cfgin ){
172         // Setup the account configuration file pointer.
173         
174         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