+
+ pageSeek++;
+
+ if (pageSeek == 1){
+ pageSeek++;
+ }
+
+ if (pageSeek == 1){
+
+ // Skip this page.
+
+ } else if (pageSeek == 2){
+
+ // Finish screen.
+
+ tabType->Hide();
+ tabConn->Hide();
+ tabFinish->Show();
+ szrNewAccount->RecalcSizes();
+
+ btnNext->Disable();
+ btnNext->SetLabel(_("Finish"));
+
+ if (txtAccountName->IsEmpty() && pageSeek == 2){
+
+ btnNext->Disable();
+
+ } else {
+
+ btnNext->Enable();
+
+ }
+
+ } else if (pageSeek == 3){
+
+ // Finished.
+
+ wxString xestiaCALPrefDirectory;
+ wxString xestiaCALDirectory;
+ wxString accountSettingsFile;
+ //wxFile ASFile;
+
+ srand(time(0));
+ int randomNumber = rand() % 32767;
+ wxString randomNumberSuffix = wxString::Format(wxT("%i"), randomNumber);
+ bool directoryCreated = FALSE;
+
+#if defined(__HAIKU__)
+
+ //preffilename = wxT("noo");
+
+#elif defined(__WIN32__)
+
+ xestiaCALPrefDirectory = GetUserPrefDir();
+ xestiaCALDirectory = GetUserDir();
+
+ accountSettingsFile = xestiaCALPrefDirectory + wxT("accounts");
+
+ // Open the file for writing.
+
+ wxFileConfig *cfgFile = new wxFileConfig("", "", accountSettingsFile);
+
+ // Check if account name already exists and return an error message
+ // if this is the case.
+
+ wxString accountName;
+ long itemIndex = 0;
+ bool continueAcc;
+ continueAcc = cfgFile->GetFirstGroup(accountName, itemIndex);
+
+ while (continueAcc){
+
+ if (txtAccountName->GetValue() == accountName){
+
+ wxMessageBox(_("The selected account name is already used, please use another account name."), _("Account name already used"), wxICON_ERROR);
+ return;
+
+ }
+
+ cfgFile->SetPath(wxT("/"));
+ continueAcc = cfgFile->GetNextGroup(accountName, itemIndex);
+
+ }
+
+ if (cmbServerType->GetCurrentSelection() == 0){
+
+ // Create the account directory.
+
+ wxString directoryName = txtAccountName->GetValue().Mid(0, 30) + randomNumberSuffix;
+
+ if (wxMkdir(xestiaCALDirectory + wxT("\\accounts\\") + directoryName + wxT(".local"), 0740) == TRUE){
+
+ directoryCreated = TRUE;
+
+ }
+
+ if (directoryCreated == TRUE){
+
+ WriteAccountDetails(cfgfile, wxT("Local"), directoryName);
+
+ } else {
+
+ wxMessageBox(_("An error occured whilst creating the account directory."), _("Cannot create account directory"));
+ return;
+
+ }
+
+ }
+
+ delete cfgFile;
+ cfgFile = NULL;
+
+ *reloadAccountConfig = TRUE;
+
+#else
+
+ xestiaCALPrefDirectory = GetUserPrefDir();
+ xestiaCALDirectory = GetUserDir();
+
+ accountSettingsFile = xestiaCALPrefDirectory + wxT("accounts");
+
+ // Open the file for writing.
+
+ wxFileConfig *cfgFile = new wxFileConfig("", "", accountSettingsFile);
+
+ // Check if account name already exists and return an error message
+ // if this is the case.
+
+ wxString accountName;
+ long itemIndex = 0;
+ bool continueAcc;
+ continueAcc = cfgfile->GetFirstGroup(accountName, itemIndex);
+
+ while (continueAcc){
+
+ if (txtAccountName->GetValue() == accountName){
+
+ wxMessageBox(_("The selected account name is already used, please use another account name."), _("Account name already used"), wxICON_ERROR);
+ return;
+
+ }
+
+ cfgFile->SetPath(wxT("/"));
+ continueAcc = cfgfile->GetNextGroup(accountName, itemIndex);
+
+ }
+
+ if (cmbServerType->GetCurrentSelection() == 0){
+
+ // Create the account directory.
+
+ wxString directoryName = txtAccountName->GetValue().Mid(0, 30) + randomNumberSuffix;
+
+ if (wxMkdir(XestiaCALDirectory + wxT("/accounts/") + directoryName + wxT(".Local"), 0740) == TRUE){
+
+ directoryCreated = TRUE;
+
+ }
+
+ if (directoryCreated == TRUE){
+
+ WriteAccountDetails(cfgfile, wxT("Local"), directoryName);
+
+ } else {
+
+ wxMessageBox(_("An error occured whilst creating the account directory."), _("Cannot create account directory"));
+ return;
+
+ }
+
+ }
+
+ delete cfgfile;
+ cfgfile = NULL;
+
+ *reloadAccountConfig = true;
+
+#endif
+
+ this->Close();
+
+ }
+