+ while(KeepUpdating == TRUE){
+
+ bool ExitLoop = FALSE;
+
+ while (ExitLoop == FALSE){
+
+ ConnHandle.SetUploadMode(FALSE);
+ ConnHandle.SetupData(wxT("DELETE"), ContactFilename, wxT(""));
+ ConnHandle.ProcessData();
+ SSLCertCollection certcol = ConnHandle.GetCertificateData();
+
+ // Check if any errors have occured whilst getting the data.
+
+ int ErrorCode = ConnHandle.GetResultCode();
+
+ if (ErrorCode != 0){
+
+ if (ErrorCode == 60 || ErrorCode == 51){
+
+ // Invalid SSL certificate so bring up a dialog to the user
+ // explaining what has happened and the options available.
+
+ // Stop all the timers.
+
+ frmMainPtrGet->PauseAllTimers();
+
+ int SSLResult;
+
+#if defined(__APPLE__)
+
+ // Bring up the trust panel and display the SSL certificate dialog.
+
+ SSLResult = DisplayTrustPanel(ConnHandle.GetTrustObject(), AccountNameFriendly);
+
+ // Update the SSL account with the trust object.
+
+ if (SSLResult != NSOKButton){
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetTrustObject());
+ iter->second = 2;
+ break;
+
+ } else {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
+
+ }
+#else
+
+ // Setup the data to be sent in the wxPostEvent command.
+
+ SSLInvalidCertNotifObj SSLICNProcData;
+
+ bool *PauseMode = new bool;
+ QRNotif qrn;
+
+ *PauseMode = TRUE;
+ qrn.QResponse = &SSLResult;
+ qrn.PausePtr = PauseMode;
+
+ SSLICNProcData.CertCollection = certcol;
+ SSLICNProcData.QRNotifData = &qrn;
+ SSLICNProcData.AccountName = AccountNameFriendly;
+
+ wxCommandEvent event(INVALIDSSLCERT);
+ event.SetClientData(&SSLICNProcData);
+ wxPostEvent(frmMainPtrGet, event);
+
+ /*timespec n1, n2;
+
+ // Fall asleep until we get an response.
+
+ n1.tv_sec = 0;
+ n1.tv_nsec = 250000000L;*/
+
+ while (*PauseMode == TRUE){
+ //nanosleep(&n1, &n2);
+ SleepFor(250000000);
+ }
+
+ // Process the response from the user.
+
+ if (SSLResult == 1){
+
+ // Accept the certificate. Write the certificate into the account
+ // directory (as server.crt) - will overwrite old certificate.
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateData());
+ WriteServerCertificate(AccountDir, ConnHandle.GetCertificateData());
+
+ } else if (SSLResult == 2){
+
+ // Reject the certificate, abort the task and mark as failed.
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetCertificateData());
+ iter->second = 2;
+ break;
+
+ }
+
+#endif
+
+ // Resume all the timers.
+
+ frmMainPtrGet->ResumeAllTimers();
+ ExitLoop = TRUE;
+
+ } else {
+
+ iter->second = 4;
+ break;
+
+ }
+
+ } else {
+
+ ExitLoop = TRUE;
+
+ }
+
+ }
+
+ if (iter->second == 2 || iter->second == 3 || iter->second == 4){
+ break;
+ }