}
btnNext->Disable();
+ btnNext->SetLabel(_("Next >"));
bool ServerResult = FALSE;
bool ServerAction = FALSE;
tabConn->Hide();
tabFinish->Show();
szrNewAccount->RecalcSizes();
-
- btnNext->Disable();
+
btnPrevious->Enable();
btnNext->SetLabel(_("Finish"));
- if (txtAccountName->IsEmpty() && pageSeek == 2){
+ if (txtAccountName->IsEmpty() || txtAccountName->GetValue().Len() < 4 && pageSeek == 3){
btnNext->Disable();
}
- if (cmbServerType->GetCurrentSelection() == 1){
+ wxString directoryName = txtAccountName->GetValue().Mid(0, 30) + randomNumberSuffix;
+
+ 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){
+ if (wxMkdir(xestiaCALDirectory + wxT("\\accounts\\") + directoryName + wxT(".local"), 0740) == true){
- directoryCreated = TRUE;
+ WriteAccountDetails(cfgFile, wxT("Local"), directoryName);
+
+ } else {
+
+ wxMessageBox(_("An error occured whilst creating the account directory."), _("Cannot create account directory"));
+ return;
}
- if (directoryCreated == TRUE){
+ } else if (cmbServerType->GetCurrentSelection() == 1){
+
+ // Create the account directory.
+
+ if (wxMkdir(xestiaCALDirectory + wxT("\\accounts\\") + directoryName + wxT(".caldav"), 0740) == true){
- WriteAccountDetails(cfgFile, wxT("Local"), directoryName);
+ WriteAccountDetails(cfgFile, wxT("CalDAV"), directoryName);
} else {
return;
}
-
+
}
delete cfgFile;
continueAcc = cfgFile->GetNextGroup(accountName, itemIndex);
}
+
+ wxString directoryName = txtAccountName->GetValue().Mid(0, 30) + randomNumberSuffix;
- if (cmbServerType->GetCurrentSelection() == 1){
+ 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){
+ if (wxMkdir(xestiaCALDirectory + wxT("/accounts/") + directoryName + wxT(".Local"), 0740) == true){
- directoryCreated = TRUE;
+ WriteAccountDetails(cfgFile, wxT("Local"), directoryName);
+
+ } else {
+
+ wxMessageBox(_("An error occured whilst creating the account directory."), _("Cannot create account directory"));
+ return;
}
- if (directoryCreated == TRUE){
-
- WriteAccountDetails(cfgFile, wxT("Local"), directoryName);
+ } else if (cmbServerType->GetCurrentSelection() == 1){
+
+ // Create the account directory.
+
+ wxString directoryName = txtAccountName->GetValue().Mid(0, 30) + randomNumberSuffix;
+
+ if (wxMkdir(xestiaCALDirectory + wxT("/accounts/") + directoryName + wxT(".caldav"), 0740) == true){
+ WriteAccountDetails(cfgFile, wxT("CalDAV"), directoryName);
+
} else {
wxMessageBox(_("An error occured whilst creating the account directory."), _("Cannot create account directory"));
}
delete cfgFile;
- cfgFile = NULL;
+ cfgFile = nullptr;
*reloadAccountConfig = true;
void frmNewAccount::UpdateResults( wxCommandEvent &event )
{
+ NewAccountResult *resultData = static_cast<NewAccountResult*>(event.GetClientData());
+
+ lblServerConnResult->SetLabel((resultData->Connected ? _("Successful") : _("Failed")));
+ lblServerResponse->SetLabel((resultData->ValidResponse ? _("Yes") : _("No")));
+ if (chkUseSSL->GetValue())
+ {
+ lblServerSSLResult->SetLabel((resultData->SSLStatus ? _("Yes") : _("No")));
+ lblServerSSLValid->SetLabel((resultData->SSLVerified == COSSL_VERIFIED ? _("Yes") : _("No")));
+ } else {
+ lblServerSSLResult->SetLabel(_("Not Applicable"));
+ lblServerSSLValid->SetLabel(_("Not Applicable"));
+ }
+ lblAbleToLoginResult->SetLabel((resultData->AuthPassed ? _("Yes") : _("No")));
+ lblCalDAVSupportResult->SetLabel((resultData->CanProcess ? _("Yes") : _("No")));
+
+ if (resultData->ErrorMessage != "")
+ {
+ lblConnectionResultText->SetLabel(_("An error occured whilst connecting to the server: ") + resultData->ErrorMessage);
+ }
+
+ if (VerifyResultData(resultData))
+ {
+ lblConnectionResultText->SetLabel(_("Successfully connected to the server. Press Next to set the account name."));
+ btnNext->Enable(true);
+ }
+ else
+ {
+ btnNext->Enable(false);
+ }
+ tabConn->Layout();
+ btnPrevious->Enable(true);
+
+ delete resultData;
+ resultData = nullptr;
+}
+
+bool frmNewAccount::VerifyResultData(NewAccountResult *resultData)
+{
+ if (!resultData->Connected) return false;
+ if (!resultData->ValidResponse) return false;
+ if (chkUseSSL->GetValue())
+ {
+ if (!resultData->SSLStatus) return false;
+ if (resultData->SSLVerified != COSSL_VERIFIED) return false;
+ }
+ if (!resultData->AuthPassed) return false;
+ if (!resultData->CanProcess) return false;
+
+ return true;
}
void frmNewAccount::RunCalDAVTest( wxCommandEvent &event )
lblServerSSLResult->SetLabel(wxT(""));
lblServerSSLValid->SetLabel(wxT(""));
lblAbleToLoginResult->SetLabel(wxT(""));
+ lblConnectionResultText->SetLabel(wxT(""));
bool usingSSLBypass = false;
// Setup a CalDAV connection object for testing.
// Test the connection.
//testConnection.SetupConnectionObject();
- CalDAVServerResult testConnectionResult = testConnection.Connect();
+ CalDAVServerResult testConnectionResult = testConnection.Connect(false);
// If server is using SSL, verify that the SSL connection is valid.
testConnection.BypassSSLVerification(true);
- CalDAVServerResult testConnectionResult = testConnection.Connect();
+ CalDAVServerResult testConnectionResult = testConnection.Connect(false);
testConnection.BypassSSLVerification(false);
// Clean up before processing response.
delete frmICPtr;
- frmICPtr = NULL;
+ frmICPtr = nullptr;
// Process the response from the user.
usingSSLBypass = true;
testConnection.BypassSSLVerification(true);
- CalDAVServerResult testConnectionResult = testConnection.Connect();
+ CalDAVServerResult testConnectionResult = testConnection.Connect(true);
testConnection.BypassSSLVerification(false);
// TODO: Integrate into the code.
//lblConnectionResultText->SetLabel(_("An error occured whilst connnecting: ") + CardDAVConn.GetErrorMessage() + wxString::Format(wxT(" (%i)\n%s"), sslcode, CardDAVConn.GetErrorBuffer().mb_str()));
+
+ resultData->Connected = true;
+ resultData->SSLStatus = true;
+ resultData->SSLVerified = COSSL_UNABLETOVERIFY;
+ resultData->ValidResponse = false;
+ resultData->AuthPassed = false;
+ resultData->CanProcess = false;
+ resultData->ErrorMessage = _("Server is using self-signed certificate and was rejected.");
+
+ wxCommandEvent resultsEvent(UPDATERESULTS);
+ resultsEvent.SetClientData(resultData);
+ wxPostEvent(this, resultsEvent);
+
+ return;
}
#endif
}
- testConnectionResult = testConnection.Connect();
+ if (usingSSLBypass == true){
+ testConnection.BypassSSLVerification(true);
+ }
+
+ testConnectionResult = testConnection.Connect(true);
// Get the server prefix if the connection was successful.
if (testConnectionResult.result == CALDAVQUERYRESULT_OK){
-
- if (usingSSLBypass == true){
- testConnection.BypassSSLVerification(true);
- }
std::string receivedServerPrefix;
receivedServerPrefix = testConnection.GetUserPrincipal();
serverPrefix = receivedServerPrefix;
- if (usingSSLBypass == true){
- testConnection.BypassSSLVerification(true);
- }
-
}
- testConnectionResult.result == CALDAVQUERYRESULT_OK ? resultData->Connected = true : resultData->Connected = false;
+ CalDAVServerSupport testConnectionSupport = testConnection.GetServerSupport();
+
+ if (usingSSLBypass == true){
+ testConnection.BypassSSLVerification(false);
+ }
+
+ (testConnectionResult.result == CALDAVQUERYRESULT_OK || testConnectionResult.result == CALDAVQUERYRESULT_SSLFAILURE) ?
+ resultData->Connected = true : resultData->Connected = false;
resultData->SSLStatus = testConnection.CanDoSSL();
resultData->SSLVerified = testConnection.SSLVerify();
resultData->ValidResponse = testConnection.HasValidResponse();
resultData->AuthPassed = testConnection.AbleToLogin();
- resultData->CanProcess = testConnection.CanDoProcessing();
+ resultData->CanProcess = testConnectionSupport.basicSupport;
resultData->ErrorMessage = testConnection.GetErrorMessage();
// Post event back confirming the tests.