X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcommon%2Fdefaults.cpp;h=924c550d55b7e4e85ecc0d781b5b65927a01213f;hb=d1663f3d3931bb05c791ef2c86926a22932c6014;hp=30455a76b7c5b9a9817c2b39166d419adac84ab9;hpb=a640cd5555cef0092393a0feacb3c9222e177fe4;p=xestiaab%2F.git diff --git a/source/common/defaults.cpp b/source/common/defaults.cpp index 30455a7..924c550 100644 --- a/source/common/defaults.cpp +++ b/source/common/defaults.cpp @@ -16,8 +16,9 @@ // You should have received a copy of the GNU General Public License along // with Xestia Address Book. If not, see -#include -#include +#include "defaults.h" + +using namespace std; void SetupDefaultAddressBook(){ @@ -28,9 +29,7 @@ void SetupDefaultAddressBook(){ wxString DefaultLocalDir; #if defined(__HAIKU__) - - //preffilename = wxT("noo"); - + #elif defined(__WIN32__) DefaultLocalDir.Clear(); @@ -74,7 +73,6 @@ void SetupDefaultSettings(){ #if defined(__HAIKU__) - //preffilename = wxT("noo"); #elif defined(__WIN32__) @@ -86,7 +84,7 @@ void SetupDefaultSettings(){ DefaultPrefDir.Clear(); DefaultPrefDir.Append(wxString::FromUTF8(getenv("HOME"))); - DefaultPrefDir.Append(wxT("/Library/Preferences/Xestia/Address Book/preferences")); + DefaultPrefDir.Append(wxT("/Library/Preferences/Xestia/Address Book/preferences/")); #else @@ -132,10 +130,64 @@ void SetupDefaultSettings(){ PrefsFile.Open(PrefsFilename, wxT("w")); #endif - PrefsFile.Write(wxT("HideLocalAddressBooks=false\nSaveWindowPosition=true\n")); + PrefsFile.Write(wxT("HideLocalAddressBooks=false\nSaveWindowPosition=true\nUseBackgroundContactColour=false\n")); } - + + // Check if the default account is in the accounts list. + // Add it if it isn't. + + wxString accountsConfigFile = DefaultPrefDir; + accountsConfigFile.Append(wxT("accounts")); + + wxFileConfig *accountConfigData = new wxFileConfig("", "", accountsConfigFile); + + long itemIndex = 0; + wxString accountName; + wxString accountType; + wxString accountDirectory; + bool continueProcessing = false; + bool defaultCalendarExists = false; + + continueProcessing = accountConfigData->GetFirstGroup(accountName, itemIndex); + + while (continueProcessing){ + + accountConfigData->SetPath(accountName); + accountConfigData->Read(wxT("type"), &accountType); + accountConfigData->Read(wxT("accountdir"), &accountDirectory); + + if (accountType == wxT("Local") && accountDirectory == wxT("Default")){ + + defaultCalendarExists = true; + + } + + continueProcessing = accountConfigData->GetNextGroup(accountName, itemIndex); + + } + + if (defaultCalendarExists == false){ + + // Create the account in the accounts file. + + accountConfigData->SetPath(wxT("/Default")); + accountConfigData->Write(wxT("type"), wxT("Local")); + accountConfigData->Write(wxT("accountdir"), wxT("Default")); + accountConfigData->Write(wxT("prefix"), wxT("")); + accountConfigData->Write(wxT("address"), wxT("")); + accountConfigData->Write(wxT("port"), wxT("")); + accountConfigData->Write(wxT("ssl"), wxT("false")); + accountConfigData->Write(wxT("username"), wxT("")); + accountConfigData->Write(wxT("password"), wxT("")); + accountConfigData->Write(wxT("prefix"), wxT("")); + accountConfigData->Write(wxT("refresh"), wxT("1800")); + + } + + delete accountConfigData; + accountConfigData = nullptr; + } void SetupDirectories(){ @@ -143,11 +195,9 @@ void SetupDirectories(){ // Create the directories if they don't exist. wxString DefaultSettingsDir; - + #if defined(__HAIKU__) - //preffilename = wxT("noo"); - #elif defined(__WIN32__) DefaultSettingsDir.Clear();