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;
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){
// XABPrefAccounts
XABPrefAccounts::XABPrefAccounts(){
- AccountsCount = 0;
+ AccountsCount = 0;
}
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;
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