X-Git-Url: http://Server1/repobrowser/?p=xestiacalendar%2F.git;a=blobdiff_plain;f=source%2Fcommon%2Fdefaults.cpp;h=4e966ba559ab7fb7f02391021032282e39059f3c;hp=998a601976db067bde4cc565db2fa38ae80decf4;hb=d4b44cdc2002d9214a0ae2528be8b1cab14c5120;hpb=1d8f15480f6e7e66bf66bcaa9ce58bed9dee8ee7 diff --git a/source/common/defaults.cpp b/source/common/defaults.cpp index 998a601..4e966ba 100644 --- a/source/common/defaults.cpp +++ b/source/common/defaults.cpp @@ -16,8 +16,7 @@ // You should have received a copy of the GNU General Public License along // with Xestia Calendar. If not, see -#include -#include +#include "defaults.h" void SetupDefaultCalendar(){ @@ -133,6 +132,59 @@ void SetupDefaultSettings(){ } + // 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(){