X-Git-Url: http://Server1/repobrowser/?p=xestiacalendar%2F.git;a=blobdiff_plain;f=source%2Fcommon%2Fpreferences.cpp;h=f43b48b9ee39653dfaada43e31279cedd2f63b1d;hp=6600116cdb89a88ed338ab80a049d99a3f419ca9;hb=22339c898f8c04af609419f036828323b26f480f;hpb=d4b44cdc2002d9214a0ae2528be8b1cab14c5120 diff --git a/source/common/preferences.cpp b/source/common/preferences.cpp index 6600116..f43b48b 100644 --- a/source/common/preferences.cpp +++ b/source/common/preferences.cpp @@ -29,233 +29,233 @@ using namespace std; void SavePreferences(); void LoadPreferences(); -XCALPreferences::XCALPreferences(wxString PreferencesFilename){ +XCALPreferences::XCALPreferences(wxString preferencesFilename){ // Load the settings into the XCALPreferences object using the // settings file received in PreferencesFilename. - wxString fullprefpath; + wxString fullPrefPath; - 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 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; - wxString firstchar; + wxString firstChar; string s; - wxString segmentname; - wxString segmentvalue; + wxString segmentName; + wxString segmentValue; // 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; + saveWindowPos = TRUE; + wxRect windowPosition; - long PosX, PosY, PosH, PosW = 0; + long posX, posY, posH, posW = 0; - bool PosXValid, PosYValid, PosHValid, PosWValid = FALSE; + bool posXValid, posYValid, posHValid, posWValid = FALSE; - PosXValid = settingfile->Read(wxT("WindowPositionX"), &PosX); - PosYValid = settingfile->Read(wxT("WindowPositionY"), &PosY); - PosHValid = settingfile->Read(wxT("WindowPositionHeight"), &PosH); - PosWValid = settingfile->Read(wxT("WindowPositionWidth"), &PosW); + posXValid = settingfile->Read(wxT("WindowPositionX"), &posX); + posYValid = settingfile->Read(wxT("WindowPositionY"), &posY); + posHValid = settingfile->Read(wxT("WindowPositionHeight"), &posH); + posWValid = settingfile->Read(wxT("WindowPositionWidth"), &posW); - if (PosXValid == TRUE && PosYValid == TRUE && PosHValid == TRUE && PosWValid == TRUE){ + if (posXValid == TRUE && posYValid == TRUE && posHValid == TRUE && posWValid == TRUE){ - WindowPosition.SetX((int)PosX); - WindowPosition.SetY((int)PosY); - WindowPosition.SetHeight((int)PosH); - WindowPosition.SetWidth((int)PosW); + windowPosition.SetX((int)posX); + windowPosition.SetY((int)posY); + windowPosition.SetHeight((int)posH); + windowPosition.SetWidth((int)posW); } else { - WindowPosition.SetX(-1); - WindowPosition.SetY(-1); - WindowPosition.SetHeight(500); - WindowPosition.SetWidth(300); + windowPosition.SetX(-1); + windowPosition.SetY(-1); + windowPosition.SetHeight(500); + windowPosition.SetWidth(300); } - SetMainWindowData(WindowPosition); + 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. - 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); - cfgfile->Read(wxT("type"), &EntryValue); + cfgFile->SetPath(accountName); + cfgFile->Read(wxT("type"), &entryValue); - if (EntryValue == wxT("Local")){ + if (entryValue == wxT("Local")){ // Get the account directory. - cfgfile->Read(wxT("accountdir"), &AccDir); + cfgFile->Read(wxT("accountdir"), &accDir); - if (AccDir.Len() > 4){ + if (accDir.Len() > 4){ - accountdirvalid = TRUE; + accountDirValid = TRUE; } else { - accountdirvalid = FALSE; + accountDirValid = FALSE; } - if (accountdirvalid == TRUE){ + if (accountDirValid == TRUE){ - accounts.AddAccount(accountname, wxT("Local"), wxT(""), 0, + accounts.AddAccount(accountName, wxT("Local"), wxT(""), 0, 0, wxT(""), wxT(""), - wxT(""), AccDir, 0); + wxT(""), accDir, 0); } - } else if (EntryValue == wxT("CalDAV")){ - - 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; + } else if (entryValue == wxT("CalDAV")){ + + 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; } else { - AccSSL = FALSE; + accSSL = FALSE; } - accountusernamevalid = cfgfile->Read(wxT("username"), &AccUsr); - accountpasswordvalid = cfgfile->Read(wxT("password"), &AccPass); - accountdirprefixvalid = cfgfile->Read(wxT("prefix"), &AccPrefix); - accountrefreshvalid = cfgfile->Read(wxT("refresh"), &AccRef); + 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. - if (accountport < 1 || accountport > 65535){ - accountport = 8008; - accountportvalid = TRUE; + if (accountPort < 1 || accountPort > 65535){ + accountPort = 8008; + accountPortValid = TRUE; } - accounts.AddAccount(accountname, wxT("CalDAV"), AccAdr, AccPort, - AccSSL, AccUsr, AccPass, - AccPrefix, AccDir, AccRef); + accounts.AddAccount(accountname, wxT("CalDAV"), accAdr, accPort, + accSSL, accUsr, accPass, + accPrefix, accDir, accRef); } else { - 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; + 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; } else { - AccSSL = FALSE; + accSSL = FALSE; } - accountusernamevalid = cfgfile->Read(wxT("username"), &AccUsr); - accountpasswordvalid = cfgfile->Read(wxT("password"), &AccPass); - accountdirprefixvalid = cfgfile->Read(wxT("prefix"), &AccPrefix); - accountrefreshvalid = cfgfile->Read(wxT("refresh"), &AccRef); + 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. - if (accountport < 1 || accountport > 65535){ - accountport = 8008; - accountportvalid = TRUE; + if (accountPort < 1 || accountPort > 65535){ + accountPort = 8008; + accountPortValid = TRUE; } - accounts.AddAccount(accountname, EntryValue, AccAdr, AccPort, - AccSSL, AccUsr, AccPass, - AccPrefix, AccDir, AccRef); + accounts.AddAccount(accountName, entryValue, 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; + 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); } @@ -265,12 +265,12 @@ XCALPreferences::~XCALPreferences(){ } -bool XCALPreferences::GetBoolData(wxString SettingName){ +bool XCALPreferences::GetBoolData(wxString settingName){ // GetBoolData from the XCALPreferences object. - if (SettingName == wxT("SaveWindowPosition")) { return SaveWindowPos; } - else if (SettingName == wxT("HideLocalAddressBooks")) { return HideLocalABs; } + if (settingName == wxT("SaveWindowPosition")) { return saveWindowPos; } + else if (settingName == wxT("HideLocalAddressBooks")) { return hideLocalABs; } return FALSE; @@ -280,15 +280,15 @@ wxRect XCALPreferences::GetMainWindowData(){ // Return the main window data as a wxRect object. - return MainWindowData; + return mainWindowData; } -void XCALPreferences::SetMainWindowData(wxRect WindowData){ +void XCALPreferences::SetMainWindowData(wxRect windowData){ // Set the main window data from a wxRect object. - MainWindowData = WindowData; + mainWindowData = WindowData; } @@ -302,33 +302,33 @@ XCALPrefAccounts::XCALPrefAccounts(){ } -int XCALPrefAccounts::AddAccount(wxString NewAccName, - wxString NewAccType, - wxString NewAccAddress, - int NewAccPort, - int NewAccSSL, - wxString NewAccUser, - wxString NewAccPass, - wxString NewAccDirPrefix, - wxString NewAccDir, - long NewAccRefresh +int XCALPrefAccounts::AddAccount(wxString newAccName, + wxString newAccType, + wxString newAccAddress, + int newAccPort, + int newAccSSL, + wxString newAccUser, + wxString newAccPass, + wxString newAccDirPrefix, + wxString newAccDir, + long newAccRefresh ){ // Add an account to the list of accounts in the // XCALPrefAccounts object. - 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; @@ -338,126 +338,126 @@ int XCALPrefAccounts::GetCount(){ // Get the count of accounts in the XCALPrefAccounts object. - return AccountsCount; + return accountsCount; } -wxString XCALPrefAccounts::GetAccountName(int AccountNum){ +wxString XCALPrefAccounts::GetAccountName(int accountNum){ // Get the account name. - if (AccountNum > AccountsCount){ + if (accountNum > accountsCount){ return wxT(""); } - return AccountName[AccountNum]; + return accountName[accountNum]; } -wxString XCALPrefAccounts::GetAccountType(int AccountNum){ +wxString XCALPrefAccounts::GetAccountType(int accountNum){ // Get the account type. - if (AccountNum > AccountsCount){ + if (accountNum > accountsCount){ return wxT(""); } - return AccountType[AccountNum]; + return accountType[accountNum]; } -wxString XCALPrefAccounts::GetAccountAddress(int AccountNum){ +wxString XCALPrefAccounts::GetAccountAddress(int accountNum){ // Get the account server address. - if (AccountNum > AccountsCount){ + if (accountNum > accountsCount){ return wxT(""); } - return AccountAddress[AccountNum]; + return accountAddress[accountNum]; } -int XCALPrefAccounts::GetAccountPort(int AccountNum){ +int XCALPrefAccounts::GetAccountPort(int accountNum){ // Get the account server port. - if (AccountNum > AccountsCount){ + if (accountNum > accountsCount){ return 0; } - return AccountPort[AccountNum]; + return accountPort[accountNum]; } -bool XCALPrefAccounts::GetAccountSSL(int AccountNum){ +bool XCALPrefAccounts::GetAccountSSL(int accountNum){ // Get the account server SSL support. - if (AccountNum > AccountsCount){ + if (accountNum > accountsCount){ return wxT(""); } - return AccountSSL[AccountNum]; + return accountSSL[accountNum]; } -wxString XCALPrefAccounts::GetAccountUsername(int AccountNum){ +wxString XCALPrefAccounts::GetAccountUsername(int accountNum){ // Get the account username. - if (AccountNum > AccountsCount){ + if (accountNum > accountsCount){ return wxT(""); } - return AccountUsername[AccountNum]; + return accountUsername[accountNum]; } -wxString XCALPrefAccounts::GetAccountPassword(int AccountNum){ +wxString XCALPrefAccounts::GetAccountPassword(int accountNum){ // Get the account password. - if (AccountNum > AccountsCount){ + if (accountNum > accountsCount){ return wxT(""); } - return AccountPassword[AccountNum]; + return accountPassword[accountNum]; } -wxString XCALPrefAccounts::GetAccountDirectory(int AccountNum){ +wxString XCALPrefAccounts::GetAccountDirectory(int accountNum){ // Get the account directory. - if (AccountNum > AccountsCount){ + if (accountNum > accountsCount){ return wxT(""); } - return AccountDirectory[AccountNum]; + return accountDirectory[accountNum]; } -wxString XCALPrefAccounts::GetAccountDirPrefix(int AccountNum){ +wxString XCALPrefAccounts::GetAccountDirPrefix(int accountNum){ // Get the account server directory prefix. - if (AccountNum > AccountsCount){ + if (accountNum > accountsCount){ return wxT(""); } - return DirectoryPrefix[AccountNum]; + return directoryPrefix[accountNum]; } -long XCALPrefAccounts::GetAccountRefresh(int AccountNum){ +long XCALPrefAccounts::GetAccountRefresh(int accountNum){ // Get the account refresh time. - if (AccountNum > AccountsCount){ + if (accountNum > accountsCount){ return 0; } - return AccountRefresh[AccountNum]; + return accountRefresh[accountNum]; } \ No newline at end of file