- if (PageSeek == 1){
-
- if (cmbServerType->GetCurrentSelection() == 0){
-
- tabType->Hide();
- tabConn->Hide();
- tabFinish->Show();
- PageSeek = 2;
- btnPrevious->Enable();
- szrNewAccount->RecalcSizes();
- btnNext->Disable();
- btnNext->SetLabel(_("Finish"));
- return;
-
- }
-
- btnNext->Disable();
-
- bool ServerResult = FALSE;
- bool ServerAction = FALSE;
- bool UseSSL = TRUE;
- wxString ServerMessage;
-
- // Connection test screen.
-
- tabType->Hide();
- tabConn->Show();
- tabFinish->Hide();
- szrNewAccount->RecalcSizes();
- btnPrevious->Enable();
-
- // Reset screen.
-
- lblServerConnResult->SetLabel(wxT(""));
- lblServerResponse->SetLabel(wxT(""));
- lblServerSSLResult->SetLabel(wxT(""));
- lblServerSSLValid->SetLabel(wxT(""));
- lblAbleToLoginResult->SetLabel(wxT(""));
- lblCardDAVSupportResult->SetLabel(wxT(""));
-
- // Spawn a thread and check if server supports CardDAV.
-
- CardDAV CardDAVConn;
-
- lblServerConnResult->SetLabel(_("Testing..."));
-
- UseSSL = chkUseSSL->GetValue();
-
- CardDAVConn.SetupConnection(txtServerAddress->GetValue(),
- wxAtoi(txtServerPort->GetValue()),
- txtUsername->GetValue(),
- txtPassword->GetValue(),
- UseSSL);
- CardDAVConn.SetupResultBools(&ServerResult, &ServerAction);
-
- std::thread ConnTest(&CardDAV::Connect, &CardDAVConn);
-
- ConnTest.join();
-
- if (ServerResult == FALSE){
-
- lblServerConnResult->SetLabel(_("Failed"));
- wxMessageBox(CardDAVConn.GetErrorMessage());
- return;
-
- } else {
-
- lblServerConnResult->SetLabel(_("Connected"));
-
- }
-
- if (CardDAVConn.HasValidResponse() == TRUE){
-
- lblServerResponse->SetLabel(_("Yes"));
-
- } else {
-
- lblServerResponse->SetLabel(_("No"));
-
- }
-
- if (CardDAVConn.CanDoSSL() == TRUE){
-
- lblCardDAVSupportResult->SetLabel(_("Used"));
-
- } else {
-
- lblServerSSLResult->SetLabel(_("Not Used"));
- lblServerSSLValid->SetLabel(_("Not Applicable"));
-
- }
-
- if (CardDAVConn.SSLVerify() == TRUE && CardDAVConn.CanDoSSL() == TRUE){
-
- lblCardDAVSupportResult->SetLabel(_("Verified"));
-
- } else if (CardDAVConn.SSLVerify() == FALSE && CardDAVConn.CanDoSSL() == TRUE) {
-
- lblServerSSLResult->SetLabel(_("Unable to verify"));
-
- }
-
- if (CardDAVConn.CanDoCardDAV() == TRUE){
-
- lblCardDAVSupportResult->SetLabel(_("Supported"));
-
- } else {
-
- lblCardDAVSupportResult->SetLabel(_("Unsupported"));
-
- }
-
- if (CardDAVConn.AbleToLogin() == TRUE){
-
- lblAbleToLoginResult->SetLabel(_("Yes"));
-
- } else {
-
- lblAbleToLoginResult->SetLabel(_("No"));
-
- }
-
- // Get the address to process CardDAV requests.
-
- ServerPrefix = CardDAVConn.GetDefaultAddressBookURL();
-
- wxMessageBox(ServerPrefix);
-
- if (ServerResult == TRUE && CardDAVConn.HasValidResponse() == TRUE &&
- //CardDAVConn.CanDoSSL() == TRUE && CardDAVConn.SSLVerify() == TRUE &&
- CardDAVConn.CanDoCardDAV() == TRUE && CardDAVConn.AbleToLogin() == TRUE){
-
- btnNext->Enable();
-
- lblConnectionResultText->SetLabel(_("Click on Next to set the account name."));
-
- } else {
-
- lblConnectionResultText->SetLabel(_("A problem has occured whilst connecting to the CardDAV server.\nPlease review the above information and change the server details if needed.\nIf there are still problems, please speak to your system administrator(s)."));
-
- }
-
- } 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 XestiaABPrefDirectory;
- wxString AccountSettingsFile;
- //wxFile ASFile;
- wxString RandomNumberSuffix = wxString::Format(wxT("%i"), rand() % 32767);
- bool DirectoryCreated = FALSE;
+ if (PageSeek == 1){
+
+ if (cmbServerType->GetCurrentSelection() == 0){
+
+ tabType->Hide();
+ tabConn->Hide();
+ tabFinish->Show();
+ PageSeek = 2;
+ btnPrevious->Enable();
+ szrNewAccount->RecalcSizes();
+ btnNext->Disable();
+ btnNext->SetLabel(_("Finish"));
+ return;
+
+ }
+
+ // Check if server address matches against the blacklist.
+ // Bring up warning message if it does.
+
+ if (CheckBlacklist(txtServerAddress->GetValue())){
+
+ int MessageBoxResult = wxMessageBox(_("The server with the address given does not support the CardDAV protocol properly and shouldn't be used.\n\nData loss is very likely.\n\nDo you still want to continue using this server?"), _("Server warning"), wxYES_NO, this);
+
+ if (MessageBoxResult == wxNO){
+ PageSeek--;
+ return;
+ }
+
+ }
+
+ btnNext->Disable();
+
+ bool ServerResult = FALSE;
+ bool ServerAction = FALSE;
+ bool UseSSL = TRUE;
+ wxString ServerMessage;
+
+ // Connection test screen.
+
+ tabType->Hide();
+ tabConn->Show();
+ tabFinish->Hide();
+ szrNewAccount->RecalcSizes();
+ btnPrevious->Disable();
+
+ // Reset screen.
+
+ lblServerConnResult->SetLabel(wxT(""));
+ lblServerResponse->SetLabel(wxT(""));
+ lblServerSSLResult->SetLabel(wxT(""));
+ lblServerSSLValid->SetLabel(wxT(""));
+ lblAbleToLoginResult->SetLabel(wxT(""));
+ lblCardDAVSupportResult->SetLabel(wxT(""));
+
+ // Depending on account type, run the test.
+
+ if (cmbServerType->GetCurrentSelection() == 1){
+ wxCommandEvent RunTest(RUNCARDDAV2TEST);
+ wxPostEvent(this, RunTest);
+ }
+
+ } 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 XestiaABPrefDirectory;
+ wxString XestiaABDirectory;
+ wxString AccountSettingsFile;
+ //wxFile ASFile;
+
+ srand(time(0));
+ int RandomNumber = rand() % 32767;
+ wxString RandomNumberSuffix = wxString::Format(wxT("%i"), RandomNumber);
+ bool DirectoryCreated = FALSE;