X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=blobdiff_plain;f=source%2Fcommon%2Fdefaults.cpp;h=9f89b0de760445444662981ffd7163d503029e8d;hp=57a8ad57b0363b14cbd0d5933d4f3deb58b805ef;hb=df3db592b57a92dd99a97d769152da1492cdea0e;hpb=9802970e8be1fe9511ad9a9d0eb9ffe8d2cfea41 diff --git a/source/common/defaults.cpp b/source/common/defaults.cpp index 57a8ad5..9f89b0d 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(){ @@ -132,7 +133,60 @@ void SetupDefaultSettings(){ PrefsFile.Write(wxT("HideLocalAddressBooks=false\nSaveWindowPosition=true\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("")); + + } + + delete accountConfigData; + accountConfigData = nullptr; + } void SetupDirectories(){