X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fforms%2Feditaccount%2FfrmEditAccount.cpp;h=58bea132b3338377510f9b4acea143efbc3e293a;hb=1fe6e43892e5c572949a293a9e19704b5debadad;hp=7afab25f32c1a29a6084799f4fed4b93e87f975b;hpb=a5f6f2cc97062e1ec82b7d50b47f68f447353073;p=xestiacalendar%2F.git diff --git a/source/forms/editaccount/frmEditAccount.cpp b/source/forms/editaccount/frmEditAccount.cpp index 7afab25..58bea13 100644 --- a/source/forms/editaccount/frmEditAccount.cpp +++ b/source/forms/editaccount/frmEditAccount.cpp @@ -1,23 +1,194 @@ +// frmEditAccount.cpp - frmEditAccount form functions. +// +// (c) 2016-2017 Xestia Software Development. +// +// This file is part of Xestia Calendar. +// +// Xestia Calendar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by the +// Free Software Foundation, version 3 of the license. +// +// Xestia Calendar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with Xestia Calendar. If not, see + #include "frmEditAccount.h" frmEditAccount::frmEditAccount( wxWindow* parent ) : frmEditAccountADT( parent ) { - + btnDetect->Enable(false); } void frmEditAccount::DetectAddressBook( wxCommandEvent& event ) { -// TODO: Implement DetectAddressBook + + // TODO: Currently unimplemented. + } 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 ) { -// 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