Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Move INSTALL, LICENSE, README, THANKS and TODO into root directory
[xestiaab/.git] / source / common / preferences.cpp
index 85981fd..e965f48 100644 (file)
@@ -30,8 +30,10 @@ void SavePreferences();
 void LoadPreferences();
 
 XABPreferences::XABPreferences(wxString PreferencesFilename){
-    
-       //fstream preffile;
+
+       // Load the settings into the XABPreferences object using the
+       // settings file received in PreferencesFilename.
+
        wxString fullprefpath;
     
        bool accountnamevalid, accountaddressvalid, accounttypevalid, accountportvalid,
@@ -70,7 +72,7 @@ XABPreferences::XABPreferences(wxString PreferencesFilename){
     
        if (ValueInc == wxT("true")){
                
-               SaveWindowPos = TRUE;
+               SaveWindowPos = true;
                wxRect WindowPosition;
        
                long PosX, PosY, PosH, PosW = 0;
@@ -105,7 +107,18 @@ XABPreferences::XABPreferences(wxString PreferencesFilename){
        settingfile->Read(wxT("HideLocalAddressBooks"), &ValueInc);
     
        if (ValueInc == wxT("true")){
-               HideLocalABs = TRUE;
+               HideLocalABs = true;
+       }
+       
+       settingfile->Read(wxT("UseBackgroundContactColour"), &ValueInc);
+    
+       if (ValueInc == wxT("true")){
+               UseBackgroundContactColour = true;
+               wxString BackgroundContactColourRead;
+               settingfile->Read(wxT("BackgroundContactColour"), &BackgroundContactColourRead);
+               if (BackgroundContactColourRead.Mid(0, 1) == "#"){
+                       BackgroundContactColour.Set(BackgroundContactColourRead);
+               }
        }
     
        delete settingfile;
@@ -132,7 +145,6 @@ XABPreferences::XABPreferences(wxString PreferencesFilename){
        while (ContinueAcc){
 
                cfgfile->SetPath(accountname);
-               //ContinueProc = cfgfile->GetFirstEntry(EntryName, subitemindex);
                cfgfile->Read(wxT("type"), &EntryValue);
          
                if (EntryValue == wxT("Local")){
@@ -168,6 +180,9 @@ XABPreferences::XABPreferences(wxString PreferencesFilename){
                        if (AccSSLInc == wxT("true")){
                                AccSSL = TRUE;
                        }
+                       else {
+                               AccSSL = FALSE;
+                       }
                        accountusernamevalid = cfgfile->Read(wxT("username"), &AccUsr);
                        accountpasswordvalid = cfgfile->Read(wxT("password"), &AccPass);
                        accountdirprefixvalid = cfgfile->Read(wxT("prefix"), &AccPrefix);
@@ -191,6 +206,41 @@ XABPreferences::XABPreferences(wxString PreferencesFilename){
                                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;
+                       }
+                       else {
+                               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);
+            
+                       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, EntryValue, AccAdr, AccPort,
+                               AccSSL, AccUsr, AccPass, 
+                               AccPrefix, AccDir, AccRef);
+                       
                }
 
                // Clear up for the next account.
@@ -228,29 +278,52 @@ XABPreferences::~XABPreferences(){
 
 bool XABPreferences::GetBoolData(wxString SettingName){
 
+       // GetBoolData from the XABPreferences object.
+
        if (SettingName == wxT("SaveWindowPosition")) { return SaveWindowPos; }
        else if (SettingName == wxT("HideLocalAddressBooks")) { return HideLocalABs; }
+       else if (SettingName == wxT("UseBackgroundContactColour")) { return UseBackgroundContactColour; }
        
-       return FALSE;
+       return false;
 
 }
 
 wxRect XABPreferences::GetMainWindowData(){
        
+       // Return the main window data as a wxRect object.
+       
        return MainWindowData;
 
 }
 
 void XABPreferences::SetMainWindowData(wxRect WindowData){
 
+       // Set the main window data from a wxRect object.
+
        MainWindowData = WindowData;
 
 }
 
+wxColour XABPreferences::GetBackgroundContactColourData(){
+       
+       return BackgroundContactColour;
+       
+}
+
+void XABPreferences::SetBackgroundContactColourData(wxColour ColourData){
+       
+       BackgroundContactColour = ColourData;
+       
+}
+
 // XABPrefAccounts
 
 XABPrefAccounts::XABPrefAccounts(){
+
+       // Setup the default values for XABPrefAccounts.
+
        AccountsCount = 0;
+       
 }
 
 int XABPrefAccounts::AddAccount(wxString NewAccName,
@@ -265,6 +338,9 @@ int XABPrefAccounts::AddAccount(wxString NewAccName,
        long NewAccRefresh
 ){
   
+       // Add an account to the list of accounts in the
+       // XABPrefAccounts object.
+  
        AccountName.Add(NewAccName, 1);
        AccountType.Add(NewAccType, 1);
        AccountAddress.Add(NewAccAddress, 1);
@@ -284,12 +360,16 @@ int XABPrefAccounts::AddAccount(wxString NewAccName,
 
 int XABPrefAccounts::GetCount(){
   
+       // Get the count of accounts in the XABPrefAccounts object.
+  
        return AccountsCount;
   
 }
 
 wxString XABPrefAccounts::GetAccountName(int AccountNum){
  
+       // Get the account name.
        if (AccountNum > AccountsCount){
                return wxT("");
        }
@@ -300,6 +380,8 @@ wxString XABPrefAccounts::GetAccountName(int AccountNum){
 
 wxString XABPrefAccounts::GetAccountType(int AccountNum){
  
+       // Get the account type.
        if (AccountNum > AccountsCount){
                return wxT("");
        }
@@ -310,6 +392,8 @@ wxString XABPrefAccounts::GetAccountType(int AccountNum){
 
 wxString XABPrefAccounts::GetAccountAddress(int AccountNum){
  
+       // Get the account server address.
        if (AccountNum > AccountsCount){
                return wxT("");
        }
@@ -320,6 +404,8 @@ wxString XABPrefAccounts::GetAccountAddress(int AccountNum){
 
 int XABPrefAccounts::GetAccountPort(int AccountNum){
  
+       // Get the account server port.
        if (AccountNum > AccountsCount){
                return 0;
        }
@@ -330,6 +416,8 @@ int XABPrefAccounts::GetAccountPort(int AccountNum){
 
 bool XABPrefAccounts::GetAccountSSL(int AccountNum){
  
+       // Get the account server SSL support.
        if (AccountNum > AccountsCount){
                return wxT("");
        }
@@ -340,6 +428,8 @@ bool XABPrefAccounts::GetAccountSSL(int AccountNum){
 
 wxString XABPrefAccounts::GetAccountUsername(int AccountNum){
  
+       // Get the account username.
        if (AccountNum > AccountsCount){
                return wxT("");
        }
@@ -350,6 +440,8 @@ wxString XABPrefAccounts::GetAccountUsername(int AccountNum){
 
 wxString XABPrefAccounts::GetAccountPassword(int AccountNum){
  
+       // Get the account password.
        if (AccountNum > AccountsCount){
                return wxT("");
        }
@@ -360,6 +452,8 @@ wxString XABPrefAccounts::GetAccountPassword(int AccountNum){
 
 wxString XABPrefAccounts::GetAccountDirectory(int AccountNum){
  
+       // Get the account directory.
        if (AccountNum > AccountsCount){
                return wxT("");
        }
@@ -370,6 +464,8 @@ wxString XABPrefAccounts::GetAccountDirectory(int AccountNum){
 
 wxString XABPrefAccounts::GetAccountDirPrefix(int AccountNum){
  
+       // Get the account server directory prefix.
        if (AccountNum > AccountsCount){
                return wxT("");
        }
@@ -380,6 +476,8 @@ wxString XABPrefAccounts::GetAccountDirPrefix(int AccountNum){
 
 long XABPrefAccounts::GetAccountRefresh(int AccountNum){
 
+       // Get the account refresh time.
+
        if (AccountNum > AccountsCount){
                return 0;
        }
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy