From 9c2e0d1d9ece1408a1c25581905ee2a65da81b69 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 2 Aug 2015 20:28:27 +0100 Subject: [PATCH] Remove unused variables and clarify the type of certain variables in XABPreferences --- source/common/preferences.cpp | 179 +++++++++++++++++----------------- 1 file changed, 88 insertions(+), 91 deletions(-) diff --git a/source/common/preferences.cpp b/source/common/preferences.cpp index 218b7b0..6fae06e 100644 --- a/source/common/preferences.cpp +++ b/source/common/preferences.cpp @@ -16,8 +16,6 @@ XABPreferences::XABPreferences(wxString PreferencesFilename){ //fstream preffile; wxString fullprefpath; - int accountnum = 0; - bool accountnamevalid, accountaddressvalid, accounttypevalid, accountportvalid, accountsslvalid, accountusernamevalid, accountpasswordvalid, accountdirprefixvalid, accountdirvalid, accountrefreshvalid = FALSE; @@ -68,10 +66,10 @@ XABPreferences::XABPreferences(wxString PreferencesFilename){ if (PosXValid == TRUE && PosYValid == TRUE && PosHValid == TRUE && PosWValid == TRUE){ - WindowPosition.SetX(PosX); - WindowPosition.SetY(PosY); - WindowPosition.SetHeight(PosH); - WindowPosition.SetWidth(PosW); + WindowPosition.SetX((int)PosX); + WindowPosition.SetY((int)PosY); + WindowPosition.SetHeight((int)PosH); + WindowPosition.SetWidth((int)PosW); } else { @@ -109,100 +107,99 @@ XABPreferences::XABPreferences(wxString PreferencesFilename){ bool AccSSL = FALSE; int AccRef, AccPort = 0; long itemindex = 0; - long subitemindex = 0; bool ContinueAcc = TRUE; - bool ContinueProc = TRUE; ContinueAcc = cfgfile->GetFirstGroup(accountname, itemindex); while (ContinueAcc){ - cfgfile->SetPath(accountname); - //ContinueProc = cfgfile->GetFirstEntry(EntryName, subitemindex); - cfgfile->Read(wxT("type"), &EntryValue); - - if (EntryValue == wxT("Local")){ - - // Get the account directory. - - cfgfile->Read(wxT("accountdir"), &AccDir); - - if (AccDir.Len() > 4){ - - accountdirvalid = TRUE; - - } else { - - accountdirvalid = FALSE; - - } - - if (accountdirvalid == TRUE){ - - 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); - - if (AccDir.Len() > 4){ - - accountdirvalid = TRUE; - - } - - // 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; - } - - accounts.AddAccount(accountname, wxT("CardDAV"), AccAdr, AccPort, - AccSSL, AccUsr, AccPass, - AccPrefix, AccDir, AccRef); - - } - - // Clear up for the next account. + cfgfile->SetPath(accountname); + //ContinueProc = cfgfile->GetFirstEntry(EntryName, subitemindex); + cfgfile->Read(wxT("type"), &EntryValue); + + if (EntryValue == wxT("Local")){ + + // Get the account directory. + + cfgfile->Read(wxT("accountdir"), &AccDir); + + if (AccDir.Len() > 4){ + + accountdirvalid = TRUE; + + } else { + + accountdirvalid = FALSE; + + } + + if (accountdirvalid == TRUE){ + + 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); + + if (AccDir.Len() > 4){ + + accountdirvalid = TRUE; + + } + + // 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; + } + + accounts.AddAccount(accountname, wxT("CardDAV"), AccAdr, AccPort, + AccSSL, AccUsr, AccPass, + AccPrefix, AccDir, AccRef); + + } + + // Clear up for the next account. - accountnamevalid, accountaddressvalid, accounttypevalid, accountportvalid, - accountsslvalid, accountusernamevalid, accountpasswordvalid, - accountdirprefixvalid, accountdirvalid, accountrefreshvalid, accountssl, - isvalidaccount, isvalidsection = FALSE; - AccAdr.Clear(); - //AccPort.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; + 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; cfgfile->SetPath(wxT("/")); - ContinueAcc = cfgfile->GetNextGroup(accountname, itemindex); + ContinueAcc = cfgfile->GetNextGroup(accountname, itemindex); + } } -- 2.39.5