From a03e20fbd95e8252ebfc2194c6b80552405bb8bd Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Fri, 11 Mar 2016 16:56:49 +0000 Subject: [PATCH] Idented code properly in common/preferences.cpp --- source/common/preferences.cpp | 338 +++++++++++++++++----------------- 1 file changed, 169 insertions(+), 169 deletions(-) diff --git a/source/common/preferences.cpp b/source/common/preferences.cpp index 22c8302..85981fd 100644 --- a/source/common/preferences.cpp +++ b/source/common/preferences.cpp @@ -31,44 +31,44 @@ void LoadPreferences(); XABPreferences::XABPreferences(wxString PreferencesFilename){ - //fstream preffile; - wxString fullprefpath; + //fstream preffile; + wxString fullprefpath; - bool accountnamevalid, accountaddressvalid, accounttypevalid, accountportvalid, - accountsslvalid, accountusernamevalid, accountpasswordvalid, - accountdirprefixvalid, accountdirvalid, accountrefreshvalid = FALSE; + bool accountnamevalid, accountaddressvalid, accounttypevalid, accountportvalid, + accountsslvalid, accountusernamevalid, accountpasswordvalid, + accountdirprefixvalid, accountdirvalid, accountrefreshvalid = FALSE; - bool preaccountstage = FALSE; - bool isvalidaccount = FALSE; - bool isvalidsection = FALSE; - wxString accountname; - wxString accountaddress; - wxString accounttype; - long accountport = 8080; - long accountrefresh; - bool accountssl; - wxString accountusername; - wxString accountpassword; - wxString accountdirprefix; - wxString accountdir; + bool preaccountstage = FALSE; + bool isvalidaccount = FALSE; + bool isvalidsection = FALSE; + wxString accountname; + wxString accountaddress; + wxString accounttype; + long accountport = 8080; + long accountrefresh; + bool accountssl; + wxString accountusername; + wxString accountpassword; + wxString accountdirprefix; + wxString accountdir; - wxString firstchar; - string s; + wxString firstchar; + string s; - wxString segmentname; - wxString segmentvalue; + wxString segmentname; + wxString segmentvalue; - // Load the settings. + // Load the settings. - fullprefpath.Append(PreferencesFilename); - fullprefpath.Append(wxT("settings")); + fullprefpath.Append(PreferencesFilename); + fullprefpath.Append(wxT("settings")); - wxFileConfig *settingfile = new wxFileConfig("", "", fullprefpath); + wxFileConfig *settingfile = new wxFileConfig("", "", fullprefpath); - wxString ValueInc; - settingfile->Read(wxT("SaveWindowPosition"), &ValueInc); + wxString ValueInc; + settingfile->Read(wxT("SaveWindowPosition"), &ValueInc); - if (ValueInc == wxT("true")){ + if (ValueInc == wxT("true")){ SaveWindowPos = TRUE; wxRect WindowPosition; @@ -100,130 +100,130 @@ XABPreferences::XABPreferences(wxString PreferencesFilename){ SetMainWindowData(WindowPosition); - } + } - settingfile->Read(wxT("HideLocalAddressBooks"), &ValueInc); + settingfile->Read(wxT("HideLocalAddressBooks"), &ValueInc); - if (ValueInc == wxT("true")){ - HideLocalABs = TRUE; - } + if (ValueInc == wxT("true")){ + HideLocalABs = TRUE; + } - delete settingfile; - settingfile = NULL; + delete settingfile; + settingfile = NULL; - // Load the accounts. + // Load the accounts. - fullprefpath.Clear(); - fullprefpath.Append(PreferencesFilename); - fullprefpath.Append(wxT("accounts")); + fullprefpath.Clear(); + fullprefpath.Append(PreferencesFilename); + fullprefpath.Append(wxT("accounts")); - wxFileConfig *cfgfile = new wxFileConfig("AddressBook", "Xestia", fullprefpath); + wxFileConfig *cfgfile = new wxFileConfig("AddressBook", "Xestia", fullprefpath); - wxString EntryName, EntryValue; - wxString AccAdr, AccUsr, AccPass, AccPrefix, AccDir; - wxString AccSSLInc; - bool AccSSL = FALSE; - int AccRef, AccPort = 0; - long itemindex = 0; - bool ContinueAcc = TRUE; + wxString EntryName, EntryValue; + wxString AccAdr, AccUsr, AccPass, AccPrefix, AccDir; + wxString AccSSLInc; + bool AccSSL = FALSE; + int AccRef, AccPort = 0; + long itemindex = 0; + bool ContinueAcc = TRUE; - ContinueAcc = cfgfile->GetFirstGroup(accountname, itemindex); + ContinueAcc = cfgfile->GetFirstGroup(accountname, itemindex); - while (ContinueAcc){ + while (ContinueAcc){ - cfgfile->SetPath(accountname); - //ContinueProc = cfgfile->GetFirstEntry(EntryName, subitemindex); - cfgfile->Read(wxT("type"), &EntryValue); + cfgfile->SetPath(accountname); + //ContinueProc = cfgfile->GetFirstEntry(EntryName, subitemindex); + cfgfile->Read(wxT("type"), &EntryValue); - if (EntryValue == wxT("Local")){ + if (EntryValue == wxT("Local")){ - // Get the account directory. - - cfgfile->Read(wxT("accountdir"), &AccDir); + // Get the account directory. + + cfgfile->Read(wxT("accountdir"), &AccDir); - if (AccDir.Len() > 4){ + if (AccDir.Len() > 4){ - accountdirvalid = TRUE; + accountdirvalid = TRUE; - } else { + } else { - accountdirvalid = FALSE; + accountdirvalid = FALSE; - } + } - if (accountdirvalid == TRUE){ + if (accountdirvalid == TRUE){ - accounts.AddAccount(accountname, wxT("Local"), wxT(""), 0, - 0, wxT(""), wxT(""), - wxT(""), AccDir, 0); + accounts.AddAccount(accountname, wxT("Local"), wxT(""), 0, + 0, wxT(""), wxT(""), + wxT(""), AccDir, 0); - } + } - } else if (EntryValue == wxT("CardDAV")){ - - cfgfile->Read(wxT("accountdir"), &AccDir); - accountaddressvalid = cfgfile->Read(wxT("address"), &AccAdr); - accountportvalid = cfgfile->Read(wxT("port"), &AccPort); - accountsslvalid = cfgfile->Read(wxT("ssl"), &AccSSLInc); - if (AccSSLInc == wxT("true")){ - AccSSL = TRUE; - } - accountusernamevalid = cfgfile->Read(wxT("username"), &AccUsr); - accountpasswordvalid = cfgfile->Read(wxT("password"), &AccPass); - accountdirprefixvalid = cfgfile->Read(wxT("prefix"), &AccPrefix); - accountrefreshvalid = cfgfile->Read(wxT("refresh"), &AccRef); + } else if (EntryValue == wxT("CardDAV")){ + + cfgfile->Read(wxT("accountdir"), &AccDir); + accountaddressvalid = cfgfile->Read(wxT("address"), &AccAdr); + accountportvalid = cfgfile->Read(wxT("port"), &AccPort); + accountsslvalid = cfgfile->Read(wxT("ssl"), &AccSSLInc); + if (AccSSLInc == wxT("true")){ + AccSSL = TRUE; + } + accountusernamevalid = cfgfile->Read(wxT("username"), &AccUsr); + accountpasswordvalid = cfgfile->Read(wxT("password"), &AccPass); + accountdirprefixvalid = cfgfile->Read(wxT("prefix"), &AccPrefix); + accountrefreshvalid = cfgfile->Read(wxT("refresh"), &AccRef); - if (AccDir.Len() > 4){ + if (AccDir.Len() > 4){ - accountdirvalid = TRUE; + accountdirvalid = TRUE; - } + } - // Make sure it is not bigger than 65535 or less than 1. - // If so, default to port 8008. + // Make sure it is not bigger than 65535 or less than 1. + // If so, default to port 8008. - if (accountport < 1 || accountport > 65535){ - accountport = 8008; - accountportvalid = TRUE; - } + if (accountport < 1 || accountport > 65535){ + accountport = 8008; + accountportvalid = TRUE; + } - accounts.AddAccount(accountname, wxT("CardDAV"), AccAdr, AccPort, - AccSSL, AccUsr, AccPass, - AccPrefix, AccDir, AccRef); + accounts.AddAccount(accountname, wxT("CardDAV"), AccAdr, AccPort, + AccSSL, AccUsr, AccPass, + AccPrefix, AccDir, AccRef); - } + } - // Clear up for the next account. + // Clear up for the next account. - accountnamevalid, accountaddressvalid, accounttypevalid, accountportvalid, - accountsslvalid, accountusernamevalid, accountpasswordvalid, - accountdirprefixvalid, accountdirvalid, accountrefreshvalid, accountssl, - isvalidaccount, isvalidsection = FALSE; + accountnamevalid, accountaddressvalid, accounttypevalid, accountportvalid, + accountsslvalid, accountusernamevalid, accountpasswordvalid, + accountdirprefixvalid, accountdirvalid, accountrefreshvalid, accountssl, + isvalidaccount, isvalidsection = FALSE; - AccAdr.Clear(); - AccDir.Clear(); - AccUsr.Clear(); - AccPass.Clear(); - AccPrefix.Clear(); - accountname.Clear(); - accountaddress.Clear(); - accounttype.Clear(); - accountport = 0; - accountrefresh = 0; - accountusername.Clear(); - accountpassword.Clear(); - accountdirprefix.Clear(); - preaccountstage = TRUE; + AccAdr.Clear(); + AccDir.Clear(); + AccUsr.Clear(); + AccPass.Clear(); + AccPrefix.Clear(); + accountname.Clear(); + accountaddress.Clear(); + accounttype.Clear(); + accountport = 0; + accountrefresh = 0; + accountusername.Clear(); + accountpassword.Clear(); + accountdirprefix.Clear(); + preaccountstage = TRUE; - cfgfile->SetPath(wxT("/")); - ContinueAcc = cfgfile->GetNextGroup(accountname, itemindex); + cfgfile->SetPath(wxT("/")); + ContinueAcc = cfgfile->GetNextGroup(accountname, itemindex); - } + } } XABPreferences::~XABPreferences(){ - + } bool XABPreferences::GetBoolData(wxString SettingName){ @@ -250,7 +250,7 @@ void XABPreferences::SetMainWindowData(wxRect WindowData){ // XABPrefAccounts XABPrefAccounts::XABPrefAccounts(){ - AccountsCount = 0; + AccountsCount = 0; } int XABPrefAccounts::AddAccount(wxString NewAccName, @@ -265,18 +265,18 @@ int XABPrefAccounts::AddAccount(wxString NewAccName, long NewAccRefresh ){ - AccountName.Add(NewAccName, 1); - AccountType.Add(NewAccType, 1); - AccountAddress.Add(NewAccAddress, 1); - AccountPort.Add(NewAccPort, 1); - AccountSSL.Add(NewAccSSL, 1); - AccountUsername.Add(NewAccUser, 1); - AccountPassword.Add(NewAccPass, 1); - DirectoryPrefix.Add(NewAccDirPrefix, 1); - AccountDirectory.Add(NewAccDir, 1); - AccountRefresh.Add(NewAccRefresh, 1); + AccountName.Add(NewAccName, 1); + AccountType.Add(NewAccType, 1); + AccountAddress.Add(NewAccAddress, 1); + AccountPort.Add(NewAccPort, 1); + AccountSSL.Add(NewAccSSL, 1); + AccountUsername.Add(NewAccUser, 1); + AccountPassword.Add(NewAccPass, 1); + DirectoryPrefix.Add(NewAccDirPrefix, 1); + AccountDirectory.Add(NewAccDir, 1); + AccountRefresh.Add(NewAccRefresh, 1); - AccountsCount++; + AccountsCount++; return 0; @@ -284,106 +284,106 @@ int XABPrefAccounts::AddAccount(wxString NewAccName, int XABPrefAccounts::GetCount(){ - return AccountsCount; + return AccountsCount; } wxString XABPrefAccounts::GetAccountName(int AccountNum){ - if (AccountNum > AccountsCount){ - return wxT(""); - } + if (AccountNum > AccountsCount){ + return wxT(""); + } - return AccountName[AccountNum]; + return AccountName[AccountNum]; } wxString XABPrefAccounts::GetAccountType(int AccountNum){ - if (AccountNum > AccountsCount){ - return wxT(""); - } + if (AccountNum > AccountsCount){ + return wxT(""); + } - return AccountType[AccountNum]; + return AccountType[AccountNum]; } wxString XABPrefAccounts::GetAccountAddress(int AccountNum){ - if (AccountNum > AccountsCount){ - return wxT(""); - } + if (AccountNum > AccountsCount){ + return wxT(""); + } - return AccountAddress[AccountNum]; + return AccountAddress[AccountNum]; } int XABPrefAccounts::GetAccountPort(int AccountNum){ - if (AccountNum > AccountsCount){ - return 0; - } + if (AccountNum > AccountsCount){ + return 0; + } - return AccountPort[AccountNum]; + return AccountPort[AccountNum]; } bool XABPrefAccounts::GetAccountSSL(int AccountNum){ - if (AccountNum > AccountsCount){ - return wxT(""); - } + if (AccountNum > AccountsCount){ + return wxT(""); + } - return AccountSSL[AccountNum]; + return AccountSSL[AccountNum]; } wxString XABPrefAccounts::GetAccountUsername(int AccountNum){ - if (AccountNum > AccountsCount){ - return wxT(""); - } + if (AccountNum > AccountsCount){ + return wxT(""); + } - return AccountUsername[AccountNum]; + return AccountUsername[AccountNum]; } wxString XABPrefAccounts::GetAccountPassword(int AccountNum){ - if (AccountNum > AccountsCount){ - return wxT(""); - } + if (AccountNum > AccountsCount){ + return wxT(""); + } - return AccountPassword[AccountNum]; + return AccountPassword[AccountNum]; } wxString XABPrefAccounts::GetAccountDirectory(int AccountNum){ - if (AccountNum > AccountsCount){ - return wxT(""); - } + if (AccountNum > AccountsCount){ + return wxT(""); + } - return AccountDirectory[AccountNum]; + return AccountDirectory[AccountNum]; } wxString XABPrefAccounts::GetAccountDirPrefix(int AccountNum){ - if (AccountNum > AccountsCount){ - return wxT(""); - } + if (AccountNum > AccountsCount){ + return wxT(""); + } - return DirectoryPrefix[AccountNum]; + return DirectoryPrefix[AccountNum]; } long XABPrefAccounts::GetAccountRefresh(int AccountNum){ - if (AccountNum > AccountsCount){ - return 0; - } + if (AccountNum > AccountsCount){ + return 0; + } - return AccountRefresh[AccountNum]; + return AccountRefresh[AccountNum]; } \ No newline at end of file -- 2.39.5