Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmEditAccount: Implemented code from Xestia Address Book
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 31 Dec 2016 22:36:39 +0000 (22:36 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 31 Dec 2016 22:36:39 +0000 (22:36 +0000)
source/forms/editaccount/frmEditAccount.cpp
source/forms/editaccount/frmEditAccount.h

index 7afab25..f4e6301 100644 (file)
@@ -4,20 +4,173 @@ frmEditAccount::frmEditAccount( wxWindow* parent )
 :
 frmEditAccountADT( parent )
 {
 :
 frmEditAccountADT( parent )
 {
-
+       btnDetect->Enable(false);
 }
 
 void frmEditAccount::DetectAddressBook( wxCommandEvent& event )
 {
 }
 
 void frmEditAccount::DetectAddressBook( wxCommandEvent& event )
 {
-// TODO: Implement DetectAddressBook
+
+       // TODO: Currently unimplemented.
+       
 }
 
 void frmEditAccount::UpdateSettings( wxCommandEvent& event )
 {
 }
 
 void frmEditAccount::UpdateSettings( wxCommandEvent& event )
 {
-// TODO: Implement UpdateSettings
+
+       // Check if server address matches against the blacklist.
+       // Bring up warning message if it does.
+       
+       if (CheckBlacklist(txtAddress->GetValue())){
+               
+               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);
+               
+               if (MessageBoxResult == wxNO){
+                       return;
+               }
+                       
+       }
+       
+       // Update the settings for the account.
+
+       long itemindex = 0;
+       bool ContinueAcc = TRUE;
+       wxString AccountName;
+
+       // Look for the account
+       
+       while (ContinueAcc){
+
+               if (AccountName == AccName){
+
+                       // Update the settings for the account.
+
+                       cfgfile->RenameGroup(AccountName, txtAccountName->GetValue());
+
+                       cfgfile->SetPath(txtAccountName->GetValue());
+                       //txtAccountName->SetValue(AccountName);
+                       
+                       cfgfile->DeleteEntry(wxT("address"), FALSE);
+                       cfgfile->Write(wxT("address"), txtAddress->GetValue());
+
+                       cfgfile->DeleteEntry(wxT("port"), FALSE);
+                       cfgfile->Write(wxT("port"), txtPort->GetValue());
+
+                       cfgfile->DeleteEntry(wxT("username"), FALSE);
+                       cfgfile->Write(wxT("username"), txtUsername->GetValue());
+
+                       cfgfile->DeleteEntry(wxT("password"), FALSE);
+                       cfgfile->Write(wxT("password"), txtPassword->GetValue());
+
+                       cfgfile->DeleteEntry(wxT("prefix"), FALSE);
+                       cfgfile->Write(wxT("prefix"), txtPrefix->GetValue());
+
+                       cfgfile->DeleteEntry(wxT("ssl"), FALSE);
+
+                       if (chkSSL->GetValue() == TRUE){
+                       
+                               cfgfile->Write(wxT("ssl"), wxT("true"));
+                       
+                       } else {
+                       
+                               cfgfile->Write(wxT("ssl"), wxT("false"));
+                       
+                       }
+
+                       cfgfile->DeleteEntry(wxT("refresh"), FALSE);
+                       cfgfile->Write(wxT("refresh"), txtRefresh->GetValue());
+
+                       break;
+
+               }
+               
+               cfgfile->SetPath(wxT("/"));
+               ContinueAcc = cfgfile->GetNextGroup(AccountName, itemindex);
+
+       }
+
+       // Set the dialog result to true and close the window.
+       
+       DialogResult = true;    
+       this->Close();
+       
+}
+
+void frmEditAccount::LoadSettings( wxString AccNameIn ){
+
+       // Get the data from the accounts settings file and
+       // fill in the account fields.
+
+       AccName = AccNameIn;
+       long itemindex = 0;
+       bool ContinueAcc = TRUE;
+       wxString AccountName;
+       wxString AccountData;
+       
+       ContinueAcc = cfgfile->GetFirstGroup(AccountName, itemindex);
+       
+       while (ContinueAcc){
+
+               if (AccountName == AccName){
+
+                       cfgfile->SetPath(AccountName);
+                       txtAccountName->SetValue(AccountName);
+
+                       cfgfile->Read("address", &AccountData);
+                       txtAddress->SetValue(AccountData);
+
+                       cfgfile->Read("port", &AccountData);
+                       txtPort->SetValue(AccountData);
+
+                       cfgfile->Read("username", &AccountData);
+                       txtUsername->SetValue(AccountData);
+
+                       cfgfile->Read("password", &AccountData);
+                       txtPassword->SetValue(AccountData);
+
+                       cfgfile->Read("prefix", &AccountData);
+                       txtPrefix->SetValue(AccountData);
+
+                       cfgfile->Read("ssl", &AccountData);
+                       if (AccountData == wxT("true")){
+                       
+                               chkSSL->SetValue(TRUE);
+                       
+                       }
+                       
+                       cfgfile->Read("refresh", &AccountData);
+                       txtRefresh->SetValue(AccountData);
+                       
+                       break;
+
+               }
+               
+               cfgfile->SetPath(wxT("/"));
+               ContinueAcc = cfgfile->GetNextGroup(AccountName, itemindex);
+
+       }
+
 }
 
 void frmEditAccount::CloseWindow( wxCommandEvent& event )
 {
 }
 
 void frmEditAccount::CloseWindow( wxCommandEvent& event )
 {
-// TODO: Implement CloseWindow
+
+       DialogResult = false;
+       this->Close();
+       
+}
+
+bool frmEditAccount::GetDialogResult(){
+
+       // Get the result of the dialog.
+       
+       return DialogResult;
+       
 }
 }
+
+void frmEditAccount::LoadPointers( wxFileConfig* cfgin ){
+
+       // Setup the account configuration file pointer.
+       
+       cfgfile = cfgin;
+
+}
\ No newline at end of file
index d19cbc6..3e69d82 100644 (file)
@@ -6,13 +6,22 @@
 Subclass of frmEditAccountADT, which is generated by wxFormBuilder.
 */
 
 Subclass of frmEditAccountADT, which is generated by wxFormBuilder.
 */
 
+#include <wx/fileconf.h>
+#include <wx/msgdlg.h>
+
 #include "../AppXestiaCalendar.h"
 
 #include "../AppXestiaCalendar.h"
 
+#include "svrblist.h"
+
 //// end generated include
 
 /** Implementing frmEditAccountADT */
 class frmEditAccount : public frmEditAccountADT
 {
 //// end generated include
 
 /** Implementing frmEditAccountADT */
 class frmEditAccount : public frmEditAccountADT
 {
+       private:
+               wxFileConfig *cfgfile;
+               wxString AccName;
+               bool DialogResult = false;
        protected:
                // Handlers for frmEditAccountADT events.
                void DetectAddressBook( wxCommandEvent& event );
        protected:
                // Handlers for frmEditAccountADT events.
                void DetectAddressBook( wxCommandEvent& event );
@@ -21,6 +30,9 @@ class frmEditAccount : public frmEditAccountADT
        public:
                /** Constructor */
                frmEditAccount( wxWindow* parent );
        public:
                /** Constructor */
                frmEditAccount( wxWindow* parent );
+               void LoadPointers( wxFileConfig* cfgin );
+               void LoadSettings( wxString AccNameIn );
+               bool GetDialogResult();
        //// end generated class members
        
 };
        //// end generated class members
        
 };
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