Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Implemented code to delete contact via ConnectionObject
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 28 Aug 2016 08:45:20 +0000 (09:45 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 28 Aug 2016 08:45:20 +0000 (09:45 +0100)
source/actmgr/frmActivityMgr-tasks.cpp
source/actmgr/frmActivityMgr.cpp
source/contacteditor/frmContactEditor-Save.cpp
source/frmMain.cpp

index 513b8fe..61ed510 100644 (file)
@@ -176,11 +176,16 @@ int frmActivityMgr::AddTask(int TaskType, wxString TaskDetail, wxString TaskAcco
                
                ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
                
+               CardDAV2 *ConnObject = new CardDAV2(AccountAddress.ToStdString(), AccountPort, AccountUsername.ToStdString(), AccountPassword.ToStdString(), AccountSSL, AccountPrefix.ToStdString(), AccountDir.ToStdString());
+               ConnObject->SetupConnectionObject();
+               
                ActivityList.insert(std::make_pair(ActivityTaskID, 0));
                ActivityListType.insert(std::make_pair(ActivityTaskID, 2));
                ActivityListData.insert(std::make_pair(ActivityTaskID, TaskData));
+               ActivityListURL.insert(std::make_pair(ActivityTaskID, TaskURL));
                ActivityListAccount.insert(std::make_pair(ActivityTaskID, TaskAccount));
                ActivityListFilename.insert(std::make_pair(ActivityTaskID, TaskFilename));
+               ActivityListConnObject.insert(std::make_pair(ActivityTaskID, ConnObject));
                ActivityListIndex.insert(std::make_pair(ActivityTaskID, itemindex));
                ActivityListAccSettings.insert(std::make_pair(ActivityTaskID, AccountSettings));
        
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;
                                
                                }
index c47ed40..f00c739 100644 (file)
@@ -470,7 +470,7 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
         
                wxString wxSETag = ETagDBPtr->GetETag(wxSplitFilename);
                wxString wxSETagOrig = ETagDBPtr->GetETagOriginal(wxSplitFilename);
-        
+
                if (wxSETagOrig.IsEmpty()){
             
                        // Generate the ETag.
@@ -484,7 +484,7 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
                        // Update empty ETag.
             
                        wxSETag = wxSETagOrig;
-                       ETagDBPtr->UpdateETag(wxSplitFilename, wxSETag, wxSETagOrig);
+                       ETagDBPtr->AddETag(wxSplitFilename, wxSETag, "");
             
                } else {
             
@@ -496,7 +496,7 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
                }
         
                if (EditMode == FALSE){
-            
+
                        ActMgrPtr->AddTask(0, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDataURL, wxSplitFilename, FilenameFinal, wxSData);
                        EditMode = TRUE;
                        FMTimer.SetFilename(FilenameFinal);
index 3c785f2..4c0e354 100644 (file)
@@ -2105,13 +2105,14 @@ void frmMain::DeleteContact(wxCommandEvent& event){
                        if (nextChild == selectedChild){
                        
                                wxSDataURL = prefaccounts.GetAccountDirPrefix(i) + wxT("/") + wxSplitFilename;
+                               break;
 
                        }
             
                }
         
                // Add task to the activity monitor to delete the contact.
-        
+               
                frameActMgr->AddTask(2, wxSContactName, ActiveAccount, wxSDataURL, wxSplitFilename, ContactsFileIndex[intContactSeekNum], wxT(""));
         
        }
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