X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Factmgr%2FfrmActivityMgr.cpp;h=1b63314d1b78ce8017d1c17f45b0b64776c65355;hb=b1467ce3cde3c61f79030bf4329f7037904043e1;hp=546795a34636352f4965eb7067e9003eabdfd094;hpb=77c692f2d711f7140eab5bc12ae445d307b961cc;p=xestiaab%2F.git diff --git a/source/actmgr/frmActivityMgr.cpp b/source/actmgr/frmActivityMgr.cpp index 546795a..1b63314 100644 --- a/source/actmgr/frmActivityMgr.cpp +++ b/source/actmgr/frmActivityMgr.cpp @@ -214,11 +214,11 @@ void frmActivityMgr::ProcessTasksThread() std::map::iterator StringETagIter; std::map::iterator StringETagOrigIter; std::map::iterator CardDAVIter; + std::map::iterator ConnObjectIter; std::map::iterator AccountSettingsIter; std::map::iterator LongIter; bool TasksFoundProc = FALSE; wxString TaskDetail; - XABPreferences PrefData(GetUserPrefDir()); for (std::map::iterator iter = ActivityList.begin(); iter != ActivityList.end(); ++iter){ @@ -236,6 +236,7 @@ void frmActivityMgr::ProcessTasksThread() // Start the animation timer if it hasn't started. CardDAVIter = ActivityListConn.find(iter->first); + ConnObjectIter = ActivityListConnObject.find(iter->first); TypeIter = ActivityListType.find(iter->first); StringETagIter = ActivityListETag.find(iter->first); StringETagOrigIter = ActivityListETagOriginal.find(iter->first); @@ -269,6 +270,7 @@ void frmActivityMgr::ProcessTasksThread() // 8 = Completed. (UI Updated). frmMain *frmMainPtrGet = static_cast(frmMainPtr); + XABPreferences PrefData(GetUserPrefDir()); if (iter->second == 0){ @@ -329,13 +331,148 @@ void frmActivityMgr::ProcessTasksThread() FullFilename = StringFullFilenameIter->second; EditMode = ActivityListEditMode.find(iter->first)->second; - bool KeepUpdating = TRUE; + bool KeepUpdating = true; - while(KeepUpdating == TRUE){ + while(KeepUpdating == true){ - bool ExitLoop = FALSE; + COConnectResult ConnectResponse = ConnObjectIter->second->Connect(false); - while (ExitLoop == FALSE){ + bool ExitLoop = false; + + while (ExitLoop == false){ + + 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; + + } + + } + + if (iter->second == 2 || iter->second == 3 || iter->second == 4){ + break; + } + +#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 + + COServerResponse AddContactResponse = ConnObjectIter->second->AddContact(StringURLIter->second.ToStdString(), + StringDataIter->second.ToStdString()); + + if (AddContactResponse.RequestResult != COREQUEST_OK){ + iter->second = 2; + break; + } + + /*while (ExitLoop == FALSE){ // Verify that we have a trusted SSL connection first. @@ -421,13 +558,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); @@ -510,7 +640,12 @@ void frmActivityMgr::ProcessTasksThread() // Add contact to the ETag DB. ConnHandle.GetServerETagValueThread(); - ETagServer = ConnHandle.ETagValueResult(); + ETagServer = ConnHandle.ETagValueResult();*/ + + // TODO: Get the entity tag for the new contact. + + + ETagDBPtr->AddETag(ContactFilename, ETagServer, ETagServer); iter->second = 4; @@ -1221,6 +1356,13 @@ 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); @@ -1459,6 +1601,11 @@ void frmActivityMgr::ProcessTasksThread() event.SetClientData(&vCardProcData); wxPostEvent(frmMainPtrGet, event); + /*timespec n1, n2; + + n1.tv_sec = 0; + n1.tv_nsec = 250000000L;*/ + while (*PauseMode == TRUE){ //nanosleep(&n1, &n2); SleepFor(250000000); @@ -1723,6 +1870,11 @@ void frmActivityMgr::ProcessTasksThread() event.SetClientData(&vCardProcData); wxPostEvent(frmMainPtrGet, event); + /*timespec n1, n2; + + n1.tv_sec = 0; + n1.tv_nsec = 250000000L;*/ + while (*PauseMode == TRUE){ //nanosleep(&n1, &n2); SleepFor(250000000); @@ -1855,6 +2007,11 @@ void frmActivityMgr::ProcessTasksThread() event.SetClientData(&vCardProcData); wxPostEvent(frmMainPtrGet, event); + /*timespec n1, n2; + + n1.tv_sec = 0; + n1.tv_nsec = 250000000L;*/ + while (*PauseMode == TRUE){ //nanosleep(&n1, &n2); SleepFor(250000000); @@ -2019,11 +2176,11 @@ void frmActivityMgr::ProcessTasksThread() KeepUpdating = FALSE; } - + } - + // Mark as completed. - + wxString AccountNameFinal; AccountNameFinal = PrefData.accounts.GetAccountDirectory(AccountID); AccountNameFinal.Append(wxT(".carddav")); @@ -2031,7 +2188,7 @@ void frmActivityMgr::ProcessTasksThread() wxCommandEvent reloadevent(RELOADCONTACTLIST); reloadevent.SetString(AccountNameFinal); wxPostEvent(this->GetParent(), reloadevent); - + iter->second = 4; continue; @@ -2194,6 +2351,26 @@ void frmActivityMgr::WriteServerCertificate(wxString AccountName, SSLCertCollect } +void frmActivityMgr::WriteServerCertificate(wxString AccountName, SSLCertCollectionString SSLCertInc){ + + wxString ServerCertFinal; + + // Get the Cert section of the certificate and write it to the file. + + ServerCertFinal = GetAccountDir(AccountName, TRUE); + + wxFile CertFile; + + std::map::iterator SSLCDIter = SSLCertInc.SSLCollection.find(0); + std::multimap::iterator SSLDataIter = SSLCDIter->second.CertData.find("Cert"); + + CertFile.Open(ServerCertFinal, wxFile::write); + + CertFile.Write(SSLDataIter->second, wxConvUTF8); + CertFile.Close(); + +} + void frmActivityMgr::StartTimer(wxCommandEvent& event){ ActListProcTimer.Start(1000, FALSE);