X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fforms%2Fnewaccount%2FfrmNewAccount.cpp;h=5b94c5e8904195a5d253465e76a6a1a0060bff1d;hb=1fe6e43892e5c572949a293a9e19704b5debadad;hp=9eb5d2418c23663fef43d7f0d8b0f95958c244bb;hpb=457d38a9a7b94871b8df70e3a595fd316ca9c4c0;p=xestiacalendar%2F.git diff --git a/source/forms/newaccount/frmNewAccount.cpp b/source/forms/newaccount/frmNewAccount.cpp index 9eb5d24..5b94c5e 100644 --- a/source/forms/newaccount/frmNewAccount.cpp +++ b/source/forms/newaccount/frmNewAccount.cpp @@ -1,3 +1,21 @@ +// frmNewAccount.cpp - frmNewAccount 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 "frmNewAccount.h" frmNewAccount::frmNewAccount( wxWindow* parent ) @@ -29,17 +47,17 @@ void frmNewAccount::ProcessPrevious( wxCommandEvent& event ) void frmNewAccount::ProcessNext( wxCommandEvent& event ) { - PageSeek++; + pageSeek++; - if (PageSeek == 1){ - PageSeek++; + if (pageSeek == 1){ + pageSeek++; } - if (PageSeek == 1){ + if (pageSeek == 1){ // Skip this page. - } else if (PageSeek == 2){ + } else if (pageSeek == 2){ // Finish screen. @@ -51,7 +69,7 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) btnNext->Disable(); btnNext->SetLabel(_("Finish")); - if (txtAccountName->IsEmpty() && PageSeek == 2){ + if (txtAccountName->IsEmpty() && pageSeek == 2){ btnNext->Disable(); @@ -61,19 +79,19 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) } - } else if (PageSeek == 3){ + } else if (pageSeek == 3){ // Finished. - wxString XestiaCALPrefDirectory; - wxString XestiaCALDirectory; - wxString AccountSettingsFile; + wxString xestiaCALPrefDirectory; + wxString xestiaCALDirectory; + wxString accountSettingsFile; //wxFile ASFile; srand(time(0)); - int RandomNumber = rand() % 32767; - wxString RandomNumberSuffix = wxString::Format(wxT("%i"), RandomNumber); - bool DirectoryCreated = FALSE; + int randomNumber = rand() % 32767; + wxString randomNumberSuffix = wxString::Format(wxT("%i"), randomNumber); + bool directoryCreated = FALSE; #if defined(__HAIKU__) @@ -81,34 +99,34 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) #elif defined(__WIN32__) - XestiaCALPrefDirectory = GetUserPrefDir(); - XestiaCALDirectory = GetUserDir(); + xestiaCALPrefDirectory = GetUserPrefDir(); + xestiaCALDirectory = GetUserDir(); - AccountSettingsFile = XestiaCALPrefDirectory + wxT("accounts"); + accountSettingsFile = xestiaCALPrefDirectory + wxT("accounts"); // Open the file for writing. - wxFileConfig *cfgfile = new wxFileConfig("", "", AccountSettingsFile); + wxFileConfig *cfgFile = new wxFileConfig("", "", accountSettingsFile); // Check if account name already exists and return an error message // if this is the case. - wxString AccountName; - long itemindex = 0; - bool ContinueAcc; - ContinueAcc = cfgfile->GetFirstGroup(AccountName, itemindex); + wxString accountName; + long itemIndex = 0; + bool continueAcc; + continueAcc = cfgFile->GetFirstGroup(accountName, itemIndex); - while (ContinueAcc){ + while (continueAcc){ - if (txtAccountName->GetValue() == AccountName){ + if (txtAccountName->GetValue() == accountName){ wxMessageBox(_("The selected account name is already used, please use another account name."), _("Account name already used"), wxICON_ERROR); return; } - cfgfile->SetPath(wxT("/")); - ContinueAcc = cfgfile->GetNextGroup(AccountName, itemindex); + cfgFile->SetPath(wxT("/")); + continueAcc = cfgFile->GetNextGroup(accountName, itemIndex); } @@ -116,17 +134,17 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) // Create the account directory. - wxString DirectoryName = txtAccountName->GetValue().Mid(0, 30) + RandomNumberSuffix; + wxString directoryName = txtAccountName->GetValue().Mid(0, 30) + randomNumberSuffix; - if (wxMkdir(XestiaCALDirectory + wxT("\\accounts\\") + DirectoryName + wxT(".local"), 0740) == TRUE){ + if (wxMkdir(xestiaCALDirectory + wxT("\\accounts\\") + directoryName + wxT(".local"), 0740) == TRUE){ - DirectoryCreated = TRUE; + directoryCreated = TRUE; } - if (DirectoryCreated == TRUE){ + if (directoryCreated == TRUE){ - WriteAccountDetails(cfgfile, wxT("Local"), DirectoryName); + WriteAccountDetails(cfgFile, wxT("Local"), directoryName); } else { @@ -137,41 +155,41 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) } - delete cfgfile; - cfgfile = NULL; + delete cfgFile; + cfgFile = NULL; - *ReloadAccountConfig = TRUE; + *reloadAccountConfig = TRUE; #else - XestiaCALPrefDirectory = GetUserPrefDir(); - XestiaCALDirectory = GetUserDir(); + xestiaCALPrefDirectory = GetUserPrefDir(); + xestiaCALDirectory = GetUserDir(); - AccountSettingsFile = XestiaCALPrefDirectory + wxT("accounts"); + accountSettingsFile = xestiaCALPrefDirectory + wxT("accounts"); // Open the file for writing. - wxFileConfig *cfgfile = new wxFileConfig("", "", AccountSettingsFile); + wxFileConfig *cfgFile = new wxFileConfig("", "", accountSettingsFile); // Check if account name already exists and return an error message // if this is the case. - wxString AccountName; - long itemindex = 0; - bool ContinueAcc; - ContinueAcc = cfgfile->GetFirstGroup(AccountName, itemindex); + wxString accountName; + long itemIndex = 0; + bool continueAcc; + continueAcc = cfgFile->GetFirstGroup(accountName, itemIndex); - while (ContinueAcc){ + while (continueAcc){ - if (txtAccountName->GetValue() == AccountName){ + if (txtAccountName->GetValue() == accountName){ wxMessageBox(_("The selected account name is already used, please use another account name."), _("Account name already used"), wxICON_ERROR); return; } - cfgfile->SetPath(wxT("/")); - ContinueAcc = cfgfile->GetNextGroup(AccountName, itemindex); + cfgFile->SetPath(wxT("/")); + continueAcc = cfgFile->GetNextGroup(accountName, itemIndex); } @@ -179,17 +197,17 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) // Create the account directory. - wxString DirectoryName = txtAccountName->GetValue().Mid(0, 30) + RandomNumberSuffix; + wxString directoryName = txtAccountName->GetValue().Mid(0, 30) + randomNumberSuffix; - if (wxMkdir(XestiaCALDirectory + wxT("/accounts/") + DirectoryName + wxT(".Local"), 0740) == TRUE){ + if (wxMkdir(xestiaCALDirectory + wxT("/accounts/") + directoryName + wxT(".Local"), 0740) == TRUE){ - DirectoryCreated = TRUE; + directoryCreated = TRUE; } - if (DirectoryCreated == TRUE){ + if (directoryCreated == TRUE){ - WriteAccountDetails(cfgfile, wxT("Local"), DirectoryName); + WriteAccountDetails(cfgFile, wxT("Local"), directoryName); } else { @@ -200,10 +218,10 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) } - delete cfgfile; - cfgfile = NULL; + delete cfgFile; + cfgFile = NULL; - *ReloadAccountConfig = true; + *reloadAccountConfig = true; #endif @@ -218,7 +236,7 @@ void frmNewAccount::CloseWindow( wxCommandEvent& event ) // Close the window. - *ReloadAccountConfig = FALSE; + *reloadAccountConfig = FALSE; this->Close(); } @@ -227,7 +245,7 @@ void frmNewAccount::SetupPointers(bool *ReloadAccountInc, CalendarDataStorage *d // Setup the pointers for the new account window. - ReloadAccountConfig = ReloadAccountInc; + reloadAccountConfig = ReloadAccountInc; } @@ -236,9 +254,9 @@ void frmNewAccount::CheckAccountName( wxCommandEvent& event ) // Check that the account name is valid. - wxString CheckAccName = txtAccountName->GetValue(); + wxString checkAccName = txtAccountName->GetValue(); - if ((txtAccountName->IsEmpty() && PageSeek == 2) || CheckAccName.Len() < 4){ + if ((txtAccountName->IsEmpty() && pageSeek == 2) || checkAccName.Len() < 4){ btnNext->Disable(); @@ -250,29 +268,29 @@ void frmNewAccount::CheckAccountName( wxCommandEvent& event ) } -void frmNewAccount::WriteAccountDetails(wxFileConfig *cfgfilein, wxString AccountType, wxString DirectoryName){ +void frmNewAccount::WriteAccountDetails(wxFileConfig *cfgFileIn, wxString accountType, wxString directoryName){ // Write the new account details. - cfgfilein->SetPath(txtAccountName->GetValue()); - cfgfilein->Write(wxT("address"), txtServerAddress->GetValue()); - cfgfilein->Write(wxT("port"), txtServerPort->GetValue()); - cfgfilein->Write(wxT("username"), txtUsername->GetValue()); - cfgfilein->Write(wxT("password"), txtPassword->GetValue()); - cfgfilein->Write(wxT("prefix"), ServerPrefix); - cfgfilein->Write(wxT("accountdir"), DirectoryName); + cfgFileIn->SetPath(txtAccountName->GetValue()); + cfgFileIn->Write(wxT("address"), txtServerAddress->GetValue()); + cfgFileIn->Write(wxT("port"), txtServerPort->GetValue()); + cfgFileIn->Write(wxT("username"), txtUsername->GetValue()); + cfgFileIn->Write(wxT("password"), txtPassword->GetValue()); + cfgFileIn->Write(wxT("prefix"), serverPrefix); + cfgFileIn->Write(wxT("accountdir"), directoryName); if (chkUseSSL->GetValue() == TRUE){ - cfgfilein->Write(wxT("ssl"), wxT("true")); + cfgFileIn->Write(wxT("ssl"), wxT("true")); } else { - cfgfilein->Write(wxT("ssl"), wxT("false")); + cfgFileIn->Write(wxT("ssl"), wxT("false")); } - cfgfilein->Write(wxT("refresh"), wxT("1800")); - cfgfilein->Write(wxT("type"), AccountType); + cfgFileIn->Write(wxT("refresh"), wxT("1800")); + cfgFileIn->Write(wxT("type"), accountType); } \ No newline at end of file