// You should have received a copy of the GNU General Public License along
// with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
-#include <wx/wx.h>
-#include <wx/ffile.h>
+#include "defaults.h"
+
+using namespace std;
void SetupDefaultAddressBook(){
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(){