Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
On Linux systems, GetCertificateData was used instead of GetSSLVerifyResults.
[xestiaab/.git] / source / actmgr / frmActivityMgr.cpp
index b63d827..b08b7b5 100644 (file)
@@ -323,16 +323,15 @@ void frmActivityMgr::ProcessTasksThread()
                                        
                                        while (ExitLoop == FALSE){
                                                
-                                               ConnHandle.SetUploadMode(TRUE);
-                                               ConnHandle.SetupData(wxT("PUT"), StringURLIter->second, StringDataIter->second);
-                                               ConnHandle.SetEditMode(EditMode);
-                                               ConnHandle.ProcessData();
-                                               
-                                               int ErrorCode = ConnHandle.GetResultCode();
+                                               // Verify that we have a trusted SSL connection first.
                                                
-                                               if (ErrorCode != 0){
+                                               int ErrorCode = ConnHandle.SSLVerifyTest();
+
+                                               if (ErrorCode != CURLE_OK){
                                                        
-                                                       if (ErrorCode == 60 || ErrorCode == 51){
+                                                       if (ErrorCode == CURLE_SSL_CACERT ||
+                                                               ErrorCode == CURLE_PEER_FAILED_VERIFICATION ||
+                                                               ErrorCode == CURLE_SSL_CONNECT_ERROR){
                                                                
                                                                // Invalid SSL certificate so bring up a dialog to the user
                                                                // explaining what has happened and the options available.
@@ -361,14 +360,37 @@ void frmActivityMgr::ProcessTasksThread()
                                                                        
                                                                        frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
                                                                        
+
+                                                               }
+
+#elif defined(__WIN32__)
+
+                                                               BOOL ModifiedCertificateData;
+                                                               CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(&ConnHandle, (HWND)frmMainPtrGet->GetHandle());
+
+                                                               if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)){
+                                                                       wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+                                                               }
+
+                                                               if (ModifiedCertificateData == FALSE){
+
+                                                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetCertificateContextPointer());
+                                                                       iter->second = 2;
+                                                                       break;
+
+                                                               } else {
+
+                                                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+
                                                                }
+
 #else
                                                                
                                                                // Setup the data to be sent in the wxPostEvent command.
                                                                
                                                                SSLInvalidCertNotifObj SSLICNProcData;
                                                                
-                                                               SSLCertCollection certcol = ConnHandle.GetCertificateData();
+                                                               SSLCertCollection certcol = ConnHandle.GetSSLVerifyResults();
                                                                
                                                                bool *PauseMode = new bool;
                                                                QRNotif qrn;
@@ -446,13 +468,31 @@ void frmActivityMgr::ProcessTasksThread()
 #if defined(__APPLE__)
                                        
                                        frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
-                                       
+
+#elif defined(__WIN32__)
+
+                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+
 #else
                                        
                                        frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateData());
                                        
 #endif
                                        
+                                       ConnHandle.SetUploadMode(TRUE);
+                                       ConnHandle.SetupData(wxT("PUT"), StringURLIter->second, StringDataIter->second);
+                                       ConnHandle.SetEditMode(EditMode);
+                                       ConnHandle.ProcessData();
+
+                                       int ErrorCode = ConnHandle.GetResultCode();
+
+                                       if (ErrorCode != CURLE_OK){
+
+                                               iter->second = 4;
+                                               break;
+
+                                       }
+
                                        // Add contact to the ETag DB.
                                        
                                        ConnHandle.GetServerETagValueThread();
@@ -460,7 +500,6 @@ void frmActivityMgr::ProcessTasksThread()
                                        ETagDBPtr->AddETag(ContactFilename, ETagServer, ETagServer);
                                        
                                        iter->second = 4;
-                                       CardDAVIter->second = NULL;
                                        break;
                                        
                                }
@@ -510,18 +549,14 @@ void frmActivityMgr::ProcessTasksThread()
                                        bool ExitLoop = FALSE;
                                        
                                        while (ExitLoop == FALSE){
+                                                
+                                               int ErrorCode = ConnHandle.SSLVerifyTest();
                                                
-                                               ConnHandle.SetUploadMode(TRUE);
-                                               ConnHandle.SetupData(wxT("PUT"), StringURLIter->second, StringDataIter->second);
-                                               ConnHandle.SetEditMode(EditMode);
-                                               ConnHandle.GetServerETagValueThread();
-                                               ETagServer = ConnHandle.ETagValueResult();
-                                               
-                                               int ErrorCode = ConnHandle.GetResultCode();
-                                               
-                                               if (ErrorCode != 0){
+                                               if (ErrorCode != CURLE_OK){
                                                        
-                                                       if (ErrorCode == 60 || ErrorCode == 51){
+                                                       if (ErrorCode == CURLE_SSL_CACERT ||
+                                                               ErrorCode == CURLE_PEER_FAILED_VERIFICATION ||
+                                                               ErrorCode == CURLE_SSL_CONNECT_ERROR){
                                                                
                                                                // Invalid SSL certificate so bring up a dialog to the user
                                                                // explaining what has happened and the options available.
@@ -551,6 +586,28 @@ void frmActivityMgr::ProcessTasksThread()
                                                                        frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
                                                                        
                                                                }
+
+#elif defined(__WIN32__)
+
+                                                               BOOL ModifiedCertificateData;
+                                                               CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(&ConnHandle, (HWND)frmMainPtrGet->GetHandle());
+
+                                                               if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)){
+                                                                       wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+                                                               }
+
+                                                               if (ModifiedCertificateData == FALSE){
+
+                                                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetCertificateContextPointer());
+                                                                       iter->second = 2;
+                                                                       break;
+
+                                                               } else {
+
+                                                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+
+                                                               }
+
 #else
                                                                
                                                                // Setup the data to be sent in the wxPostEvent command.
@@ -628,13 +685,30 @@ void frmActivityMgr::ProcessTasksThread()
 #if defined(__APPLE__)
                                        
                                        frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
-                                       
+
+#elif defined(__WIN32__)
+
+                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+
 #else
                                        
                                        frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateData());
                                        
 #endif
                                        
+                                       ConnHandle.SetUploadMode(TRUE);
+                                       ConnHandle.SetupData(wxT("PUT"), StringURLIter->second, StringDataIter->second);
+                                       ConnHandle.SetEditMode(EditMode);
+                                       ConnHandle.GetServerETagValueThread();
+                                       ETagServer = ConnHandle.ETagValueResult();
+
+                                       int ErrorCode = ConnHandle.GetResultCode();
+
+                                       if (ErrorCode != CURLE_OK){
+                                               iter->second = 2;
+                                               break;
+                                       }
+
                                        // Compare the ETag with the Server ETag.
                                        
                                        if (ETagOriginal != ETagServer){
@@ -780,18 +854,13 @@ void frmActivityMgr::ProcessTasksThread()
                                        
                                        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){
+                                               int ErrorCode = ConnHandle.SSLVerifyTest();
+
+                                               if (ErrorCode != CURLE_OK){
                                                        
-                                                       if (ErrorCode == 60 || ErrorCode == 51){
+                                                       if (ErrorCode == CURLE_SSL_CACERT ||
+                                                               ErrorCode == CURLE_PEER_FAILED_VERIFICATION ||
+                                                               ErrorCode == CURLE_SSL_CONNECT_ERROR){
                                                                
                                                                // Invalid SSL certificate so bring up a dialog to the user
                                                                // explaining what has happened and the options available.
@@ -821,12 +890,36 @@ void frmActivityMgr::ProcessTasksThread()
                                                                        frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
                                                                        
                                                                }
+
+#elif defined(__WIN32__)
+
+                                                               BOOL ModifiedCertificateData;
+                                                               CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(&ConnHandle, (HWND)frmMainPtrGet->GetHandle());
+
+                                                               if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)){
+                                                                       wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+                                                               }
+
+                                                               if (ModifiedCertificateData == FALSE){
+
+                                                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetCertificateContextPointer());
+                                                                       iter->second = 2;
+                                                                       break;
+
+                                                               } else {
+
+                                                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+
+                                                               }
+
 #else
                                                                
                                                                // Setup the data to be sent in the wxPostEvent command.
                                                                
                                                                SSLInvalidCertNotifObj SSLICNProcData;
                                                                
+                                                               SSLCertCollection certcol = ConnHandle.GetSSLVerifyResults();
+                                                               
                                                                bool *PauseMode = new bool;
                                                                QRNotif qrn;
                                                                
@@ -903,13 +996,31 @@ void frmActivityMgr::ProcessTasksThread()
 #if defined(__APPLE__)
                                
                                        frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
-                               
+
+#elif defined(__WIN32__)
+
+                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+
 #else
                                
                                        frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateData());
                                
 #endif
 
+                                       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 != CURLE_OK){
+                                               iter->second = 2;
+                                               break;
+                                       }
                                
                                        ETagDBPtr->RemoveETag(ContactFilename);
                                
@@ -1013,21 +1124,16 @@ void frmActivityMgr::ProcessTasksThread()
                                        std::map<wxString,FileSyncData> *SCListData = NULL;
                                        
                                        while (ExitLoop == FALSE){
-                                       
-                                               ServerContactList = ConnHandle.GetContactList(SyncTokenLoad.ToUTF8());
-                                               SSLCertCollection certcol = ConnHandle.GetCertificateData();
-                               
-                                               // Create a pointer for the std::map<wxString,FileSyncData>.
-                               
-                                               SCListData = &ServerContactList.ListData;
                                
                                                // Check if any errors have occured whilst getting the data.
                                
-                                               int ErrorCode = ConnHandle.GetResultCode();
+                                               int ErrorCode = ConnHandle.SSLVerifyTest();
                                
-                                               if (ErrorCode != 0){
+                                               if (ErrorCode != CURLE_OK){
                                        
-                                                       if (ErrorCode == 60 || ErrorCode == 51){
+                                                       if (ErrorCode == CURLE_SSL_CACERT ||
+                                                               ErrorCode == CURLE_PEER_FAILED_VERIFICATION ||
+                                                               ErrorCode == CURLE_SSL_CONNECT_ERROR){
                                                
                                                                // Invalid SSL certificate so bring up a dialog to the user
                                                                // explaining what has happened and the options available.
@@ -1057,12 +1163,35 @@ void frmActivityMgr::ProcessTasksThread()
                                                                         frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
                                                                         
                                                                 }
+
+#elif defined(__WIN32__)
+
+                                                               BOOL ModifiedCertificateData;
+                                                               CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(&ConnHandle, (HWND)frmMainPtrGet->GetHandle());
+
+                                                               if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)){
+                                                                       wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+                                                               }
+
+                                                               if (ModifiedCertificateData == FALSE){
+
+                                                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetCertificateContextPointer());
+                                                                       iter->second = 2;
+                                                                       break;
+
+                                                               } else {
+
+                                                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+
+                                                               }
 #else
                                 
                                                                // Setup the data to be sent in the wxPostEvent command.
 
                                                                SSLInvalidCertNotifObj SSLICNProcData;
 
+                                                               SSLCertCollection certcol = ConnHandle.GetSSLVerifyResults();
+
                                                                bool *PauseMode = new bool;
                                                                QRNotif qrn;
 
@@ -1139,7 +1268,11 @@ void frmActivityMgr::ProcessTasksThread()
 #if defined(__APPLE__)
                                         
                                         frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
-                                        
+
+#elif defined(__WIN32__)
+
+                                       frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+
 #else
                                         
                                        frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateData());
@@ -1159,6 +1292,23 @@ void frmActivityMgr::ProcessTasksThread()
                                
                                        bool ContinueProcess = AccDir.GetFirst(&AccDirFilename, wxEmptyString, wxDIR_DEFAULT);
                                
+                                       ServerContactList = ConnHandle.GetContactList(SyncTokenLoad.ToUTF8());
+
+                                       int ErrorCode = ConnHandle.GetResultCode();
+
+                                       if (ErrorCode != CURLE_OK){
+
+                                               iter->second = 4;
+                                               break;
+
+                                       }
+
+                                       SSLCertCollection certcol = ConnHandle.GetCertificateData();
+
+                                       // Create a pointer for the std::map<wxString,FileSyncData>.
+
+                                       SCListData = &ServerContactList.ListData;
+
                                        // Process the server data.
 
                                        if (SCListData != NULL){
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy