Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Implemented code to delete contact via ConnectionObject
[xestiaab/.git] / source / actmgr / frmActivityMgr.cpp
index 606b9f1..e60ce73 100644 (file)
@@ -651,7 +651,9 @@ void frmActivityMgr::ProcessTasksThread()
                                                break;
                                        }
                                        
-                                       ETagDBPtr->AddETag(ContactFilename, ETagGetResponse.EntityTag, ETagGetResponse.EntityTag);
+                                       std::cout << ETagGetResponse.EntityTag << std::endl;
+                                       
+                                       ETagDBPtr->UpdateETag(ContactFilename, ETagGetResponse.EntityTag, ETagGetResponse.EntityTag);
                                        
                                        iter->second = 4;
                                        break;
@@ -826,9 +828,6 @@ void frmActivityMgr::ProcessTasksThread()
                                        
                                        // Compare the ETag with the Server ETag.
                                        
-                                       std::cout << ETagOriginal << std::endl;
-                                       std::cout << ETagServer << std::endl;
-                                       
                                        if (ETagOriginal != ETagServer){
                                                
                                                // Server ETag is different from original ETag.
@@ -1200,9 +1199,6 @@ void frmActivityMgr::ProcessTasksThread()
                                                break;
                                        }
                                        
-                                       std::cout << "Etag Update!" << std::endl;
-                                       std::cout << ETagGetResponse.EntityTag << std::endl;
-                                       
                                        ETagDBPtr->UpdateETag(ContactFilename, ETagGetResponse.EntityTag, ETagGetResponse.EntityTag);
                                        
                                        iter->second = 4;
@@ -1242,11 +1238,116 @@ void frmActivityMgr::ProcessTasksThread()
                                
                                while(KeepUpdating == TRUE){
                                
+                                       COConnectResult ConnectResponse = ConnObjectIter->second->Connect(false);
+                                       
                                        bool ExitLoop = FALSE;
                                        
                                        while (ExitLoop == FALSE){
                                                
-                                               int ErrorCode = ConnHandle.SSLVerifyTest();
+                                               if (ConnObjectIter->second->SSLVerify() == COSSL_UNABLETOVERIFY){
+                                                       
+                                                       frmMainPtrGet->PauseAllTimers();
+                                                       
+#if defined(__APPLE__)
+#elif defined(__WIN32__)
+#else
+       
+                                                       bool UsingSSLBypass = false;
+                                                       int SSLResult = 0;
+                                                       
+                                                       // Connect again and fetch SSL certificate information.
+               
+                                                       ConnObjectIter->second->BypassSSLVerification(true);
+               
+                                                       COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
+
+                                                       ConnObjectIter->second->BypassSSLVerification(false);
+
+                                                       SSLInvalidCertNotifObjString SSLICNProcData;
+                                                       
+                                                       SSLCertCollectionString certcol = ConnObjectIter->second->BuildSSLCollection();
+                                                               
+                                                       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(INVALIDSSLCERTSTRING);
+                                                       event.SetClientData(&SSLICNProcData);
+                                                       wxPostEvent(frmMainPtrGet, event);
+                                                               
+                                                       while (*PauseMode == TRUE){
+                                                               //nanosleep(&n1, &n2);
+                                                               SleepFor(250000000);
+                                                       }
+                                                       
+                                                       // Process the response from the user.
+                                                       
+                                                       if (SSLResult == 1){
+                                                               
+                                                               // Accept the Certificate.
+
+                                                               UsingSSLBypass = true;
+                                                               ConnObjectIter->second->BypassSSLVerification(true);
+               
+                                                               COConnectResult TestConnectionResult = ConnObjectIter->second->Connect(true);
+                                                               WriteServerCertificate(AccountDir, certcol);
+                                                               
+                                                               ConnObjectIter->second->BypassSSLVerification(false);
+                                                               
+                                                       } else if (SSLResult == 2){
+                                               
+                                                               // Reject the certificate, abort the task and mark as failed.
+
+                                                               iter->second = 2;
+                                                               break;
+                                                               
+                                                       }
+               
+#endif
+                                                       
+                                                       frmMainPtrGet->ResumeAllTimers();
+                                                       ExitLoop = true;
+                                                       
+                                               } else if (ConnectResponse == COCONNECT_AUTHFAIL){
+                                                       
+                                                       ConnectResponse = ConnObjectIter->second->Connect(true);
+                                                       
+                                                       if (ConnectResponse == COCONNECT_OK){
+                                                               
+                                                               ExitLoop = true;
+                                                               break;
+                                                               
+                                                       } else {
+                                                               
+                                                               ExitLoop = true;                                                        
+                                                               iter->second = 2;
+                                                               break;
+                                                               
+                                                       }
+                                                       
+                                               } else if (ConnectResponse == COCONNECT_OK){
+                                                       
+                                                       ConnectResponse = ConnObjectIter->second->Connect(true);
+                                                       
+                                                       ExitLoop = true;
+                                                       break;
+                                                       
+                                               } else {
+                                                       
+                                                       ExitLoop = true;                                                        
+                                                       iter->second = 2;
+                                                       break;
+                                                       
+                                               }
+                                               
+                                               /*int ErrorCode = ConnHandle.SSLVerifyTest();
 
                                                if (ErrorCode != CURLE_OK){
                                                        
@@ -1327,13 +1428,6 @@ void frmActivityMgr::ProcessTasksThread()
                                                                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);
@@ -1377,7 +1471,7 @@ void frmActivityMgr::ProcessTasksThread()
                                                
                                                        ExitLoop = TRUE;
                                                
-                                               }
+                                               }*/
                                        
                                        }
                                
@@ -1399,7 +1493,7 @@ void frmActivityMgr::ProcessTasksThread()
                                
 #endif
 
-                                       ConnHandle.SetUploadMode(FALSE);
+                                       /*ConnHandle.SetUploadMode(FALSE);
                                        ConnHandle.SetupData(wxT("DELETE"), ContactFilename, wxT(""));
                                        ConnHandle.ProcessData();
                                        
@@ -1412,12 +1506,19 @@ void frmActivityMgr::ProcessTasksThread()
                                        if (ErrorCode != CURLE_OK){
                                                iter->second = 2;
                                                break;
+                                       }*/
+                                       
+                                       COServerResponse DeleteContactResponse = ConnObjectIter->second->DeleteContact(ContactFilename.ToStdString());
+                                       
+                                       if (DeleteContactResponse.RequestResult != COREQUEST_OK){
+                                               iter->second = 2;
+                                               break;
                                        }
                                
                                        ETagDBPtr->RemoveETag(ContactFilename);
                                
                                        iter->second = 4;
-                                       CardDAVIter->second = NULL;
+                                       //CardDAVIter->second = NULL;
                                        break;
                                
                                }
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