ActListProcTimer.SetupPointers(&ActivityList, &ActivityListIndex, &ActivityListTaskDetail,
&TasksActive, lstActivity, lblDetails, GauProgress, this, &AnimationTimer,
- &ActProcessTimer, &ActivityListFinDate, &ActivityListConn);
+ &ActProcessTimer, &ActivityListFinDate, &ActivityListConnObject);
AnimationTimer.SetBitmap(bmpActivity);
AnimationTimer.SetSleepBitmap(&SleepBitmap);
std::map<int,wxString>::iterator StringTaskDetailIter;
std::map<int,wxString>::iterator StringETagIter;
std::map<int,wxString>::iterator StringETagOrigIter;
- std::map<int,CardDAV*>::iterator CardDAVIter;
+ std::map<int,ConnectionObject*>::iterator ConnObjectIter;
std::map<int,ActivityMgrAccountSettings>::iterator AccountSettingsIter;
std::map<int,long>::iterator LongIter;
bool TasksFoundProc = FALSE;
wxString TaskDetail;
- XABPreferences PrefData(GetUserPrefDir());
for (std::map<int,int>::iterator iter = ActivityList.begin();
iter != ActivityList.end(); ++iter){
// 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);
// Setup the CardDAV object.
- CardDAV ConnHandle;
-
- ConnHandle.SetupConnection(AccountSettingsIter->second.Address,
- AccountSettingsIter->second.Port,
- AccountSettingsIter->second.Username,
- AccountSettingsIter->second.Password,
- AccountSettingsIter->second.SSL,
- AccountSettingsIter->second.Prefix,
- AccountSettingsIter->second.Dir);
- ConnHandle.SetupVariables(&ActivityList, iter->first);
- ConnHandle.SetupResultBools(&BlankBool, &BlankBool);
-
// 0 = Queued.
// 1 = Processing.
// 2 = Failed.
// 8 = Completed. (UI Updated).
frmMain *frmMainPtrGet = static_cast<frmMain*>(frmMainPtr);
+ XABPreferences PrefData(GetUserPrefDir());
if (iter->second == 0){
-
- //CardDAVIter->second.
// Wait for process to finish.
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){
-
- // Verify that we have a trusted SSL connection first.
+ bool ExitLoop = false;
+
+ while (ExitLoop == false){
- int ErrorCode = ConnHandle.SSLVerifyTest();
-
- if (ErrorCode != CURLE_OK){
+ if (ConnObjectIter->second->SSLVerify() == COSSL_UNABLETOVERIFY){
+
+ frmMainPtrGet->PauseAllTimers();
- 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.
-
- // Stop all the timers.
-
- frmMainPtrGet->PauseAllTimers();
-
- int SSLResult;
-
#if defined(__APPLE__)
+
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
+
+ ConnObjectIter->second->BypassSSLVerification(false);
+
+ int SSLResult = DisplayTrustPanel(ConnObjectIter->second->BuildSSLCollection(), AccountNameFriendly);
+
+ if (SSLResult != NSOKButton){
- // Bring up the trust panel and display the SSL certificate dialog.
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnObjectIter->second->BuildSSLCollection());
+ iter->second = 2;
+ break;
- SSLResult = DisplayTrustPanel(ConnHandle.GetTrustObject(), AccountNameFriendly);
+ } else {
- // Update the SSL account with the trust object.
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
- if (SSLResult != NSOKButton){
-
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetTrustObject());
- iter->second = 2;
- break;
-
- } else {
-
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
-
+ }
+
+#elif defined(__WIN32__)
- }
+ ConnObjectIter->second->BypassSSLVerification(true);
-#elif defined(__WIN32__)
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
- BOOL ModifiedCertificateData;
- CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(&ConnHandle, (HWND)frmMainPtrGet->GetHandle());
+ ConnObjectIter->second->BypassSSLVerification(false);
- if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)){
- wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
- }
+ BOOL ModifiedCertificateData = false;
+ CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(ConnObjectIter->second, (HWND)frmMainPtrGet->GetHandle());
- if (ModifiedCertificateData == FALSE){
+ if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)) {
+ wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+ }
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetCertificateContextPointer());
- iter->second = 2;
- break;
+ if (ModifiedCertificateData == false) {
- } else {
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnObjectIter->second->BuildSSLCollection());
+ iter->second = 2;
+ break;
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+ } else {
- }
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
+
+ }
#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();
- // Setup the data to be sent in the wxPostEvent command.
-
- SSLInvalidCertNotifObj SSLICNProcData;
-
- SSLCertCollection certcol = ConnHandle.GetSSLVerifyResults();
+ bool *PauseMode = new bool;
+ QRNotif qrn;
- bool *PauseMode = new bool;
- QRNotif qrn;
+ *PauseMode = TRUE;
+ qrn.QResponse = &SSLResult;
+ qrn.PausePtr = PauseMode;
- *PauseMode = TRUE;
- qrn.QResponse = &SSLResult;
- qrn.PausePtr = PauseMode;
+ SSLICNProcData.CertCollection = certcol;
+ SSLICNProcData.QRNotifData = &qrn;
+ SSLICNProcData.AccountName = AccountNameFriendly;
- SSLICNProcData.CertCollection = certcol;
- SSLICNProcData.QRNotifData = &qrn;
- SSLICNProcData.AccountName = AccountNameFriendly;
+ wxCommandEvent event(INVALIDSSLCERTSTRING);
+ event.SetClientData(&SSLICNProcData);
+ wxPostEvent(frmMainPtrGet, event);
- 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){
- while (*PauseMode == TRUE){
- //nanosleep(&n1, &n2);
- SleepFor(250000000);
- }
+ // Accept the Certificate.
+
+ UsingSSLBypass = true;
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult TestConnectionResult = ConnObjectIter->second->Connect(true);
+ WriteServerCertificate(AccountDir, certcol);
- // Process the response from the user.
+ ConnObjectIter->second->BypassSSLVerification(false);
- 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;
-
- }
+ } 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){
- // Resume all the timers.
-
- frmMainPtrGet->ResumeAllTimers();
- ExitLoop = TRUE;
+ 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;
+ ExitLoop = true;
+ iter->second = 2;
+ break;
}
#if defined(__APPLE__)
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
#elif defined(__WIN32__)
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
#else
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateData());
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
#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;
+ COServerResponse AddContactResponse = ConnObjectIter->second->AddContact(StringURLIter->second.ToStdString(),
+ StringDataIter->second.ToStdString());
+
+ if (AddContactResponse.RequestResult != COREQUEST_OK){
+ iter->second = 2;
break;
-
}
-
- // Add contact to the ETag DB.
- ConnHandle.GetServerETagValueThread();
- ETagServer = ConnHandle.ETagValueResult();
- ETagDBPtr->AddETag(ContactFilename, ETagServer, ETagServer);
+ // Get the entity tag for the new contact.
+
+ COServerResponse ETagGetResponse = ConnObjectIter->second->GetServerEntityTagValue(StringURLIter->second.ToStdString());
+
+ if (ETagGetResponse.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
+
+ ETagDBPtr->UpdateETag(ContactFilename, ETagGetResponse.EntityTag, ETagGetResponse.EntityTag);
iter->second = 4;
break;
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){
-
- int ErrorCode = ConnHandle.SSLVerifyTest();
+ bool ExitLoop = false;
+
+ while(ExitLoop == false){
- if (ErrorCode != CURLE_OK){
+ if (ConnObjectIter->second->SSLVerify() == COSSL_UNABLETOVERIFY){
+
+ frmMainPtrGet->PauseAllTimers();
- 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.
-
- // Stop all the timers.
-
- frmMainPtrGet->PauseAllTimers();
-
- int SSLResult;
-
#if defined(__APPLE__)
+
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
+
+ ConnObjectIter->second->BypassSSLVerification(false);
+
+ int SSLResult = DisplayTrustPanel(ConnObjectIter->second->BuildSSLCollection(), AccountNameFriendly);
+
+ if (SSLResult != NSOKButton){
- // Bring up the trust panel and display the SSL certificate dialog.
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnObjectIter->second->BuildSSLCollection());
+ iter->second = 2;
+ break;
- SSLResult = DisplayTrustPanel(ConnHandle.GetTrustObject(), AccountNameFriendly);
+ } else {
- // Update the SSL account with the trust object.
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
- if (SSLResult != NSOKButton){
-
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetTrustObject());
- iter->second = 2;
- break;
-
- } else {
-
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
-
- }
-
+ }
+
#elif defined(__WIN32__)
- BOOL ModifiedCertificateData;
- CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(&ConnHandle, (HWND)frmMainPtrGet->GetHandle());
+ ConnObjectIter->second->BypassSSLVerification(true);
- if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)){
- wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
- }
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
- if (ModifiedCertificateData == FALSE){
+ ConnObjectIter->second->BypassSSLVerification(false);
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetCertificateContextPointer());
- iter->second = 2;
- break;
+ BOOL ModifiedCertificateData = false;
+ CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(ConnObjectIter->second, (HWND)frmMainPtrGet->GetHandle());
- } else {
+ if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)) {
+ wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+ }
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+ if (ModifiedCertificateData == FALSE) {
- }
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnObjectIter->second->BuildSSLCollection());
+ iter->second = 2;
+ break;
+
+ } else {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
+
+ }
#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();
- // Setup the data to be sent in the wxPostEvent command.
+ bool *PauseMode = new bool;
+ QRNotif qrn;
- SSLInvalidCertNotifObj SSLICNProcData;
+ *PauseMode = TRUE;
+ qrn.QResponse = &SSLResult;
+ qrn.PausePtr = PauseMode;
- SSLCertCollection certcol = ConnHandle.GetSSLVerifyResults();
+ SSLICNProcData.CertCollection = certcol;
+ SSLICNProcData.QRNotifData = &qrn;
+ SSLICNProcData.AccountName = AccountNameFriendly;
- bool *PauseMode = new bool;
- QRNotif qrn;
+ wxCommandEvent event(INVALIDSSLCERTSTRING);
+ event.SetClientData(&SSLICNProcData);
+ wxPostEvent(frmMainPtrGet, event);
- *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);
+ while (*PauseMode == TRUE){
+ SleepFor(250000000);
+ }
+
+ // Process the response from the user.
+
+ if (SSLResult == 1){
- while (*PauseMode == TRUE){
- //nanosleep(&n1, &n2);
- SleepFor(250000000);
- }
+ // Accept the Certificate.
+
+ UsingSSLBypass = true;
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult TestConnectionResult = ConnObjectIter->second->Connect(true);
+ WriteServerCertificate(AccountDir, certcol);
- // Process the response from the user.
+ ConnObjectIter->second->BypassSSLVerification(false);
- 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.GetSSLVerifyResults());
- WriteServerCertificate(AccountDir, ConnHandle.GetSSLVerifyResults());
-
- } else if (SSLResult == 2){
-
- // Reject the certificate, abort the task and mark as failed.
-
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetSSLVerifyResults());
- iter->second = 2;
- break;
-
- }
+ } 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){
- // Resume all the timers.
-
- frmMainPtrGet->ResumeAllTimers();
- ExitLoop = TRUE;
+ 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;
+ ExitLoop = true;
+ iter->second = 2;
+ break;
}
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.GetSSLVerifyResults());
+ COServerResponse ETagGetResponse = ConnObjectIter->second->GetServerEntityTagValue(StringURLIter->second.ToStdString());
-#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){
+ if (ETagGetResponse.RequestResult != COREQUEST_OK){
iter->second = 2;
break;
}
-
+
+ ETagServer = ETagGetResponse.EntityTag;
+
// Compare the ETag with the Server ETag.
if (ETagOriginal != ETagServer){
// This is a conflict which the user will now
// need to resolve.
- vCard Moo1;
- vCard Moo2;
-
frmMain *frmMainPtrGet = static_cast<frmMain*>(frmMainPtr);
vCard34Conv vCard34Obj;
- wxString ServerContactData;
+ std::string ServerContactData;
+ wxString wxStringServerContactData;
vCard ClientData;
vCard ConvertedV4Data;
// Load the client data from the filename given.
- ConnHandle.GetServerContactData();
- ServerContactData = ConnHandle.GetPageData();
+ COServerResponse GetContactResponse = ConnObjectIter->second->GetContact(StringURLIter->second.ToStdString(),
+ &ServerContactData);
+
+ if (GetContactResponse.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
+
+ wxStringServerContactData = wxString::FromUTF8((const char*)ServerContactData.c_str());
// Process v3 version into v4 version.
- vCard34Obj.ConvertToV4(&ServerContactData, &ConvertedV4Data);
+ vCard34Obj.ConvertToV4(&wxStringServerContactData, &ConvertedV4Data);
vCardConflictObj vCardProcData;
vCardProcData.vCardServerData = &ConvertedV4Data;
ClientData.LoadFile(FullFilename);
- //ContactConflictEvent event(ContactConflictCmdEnv);
- //event.SetData(ContactFilename, Moo1, Moo2);
-
- //wxPostEvent(frmMainPtrGet, event);
-
// Setup Conflict Resolution Dialog.
// Fetch Data from Server and convert.
wxPostEvent(frmMainPtrGet, event);
while (*PauseMode == TRUE){
- //nanosleep(&n1, &n2);
SleepFor(250000000);
}
delete PauseMode;
PauseMode = NULL;
- //intResult = frmMainPtrGet->ShowConflictDialog(&Moo1, &Moo2);
-
if (ConflictResult == 0){
// Decide Later.
// Decided to use client version.
- ConnHandle.ProcessData();
-
} else if (ConflictResult == 2){
// Decided to use server version.
} else {
- // Update the data to the server.
+ // Upload the data to the server.
- ConnHandle.ProcessData();
+ COServerResponse EditContactResponse = ConnObjectIter->second->EditContact(StringURLIter->second.ToStdString(),
+ StringDataIter->second.ToStdString());
+
+ if (EditContactResponse.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
}
- // Update the ETag DB.
+ ETagGetResponse = ConnObjectIter->second->GetServerEntityTagValue(StringURLIter->second.ToStdString());
- ConnHandle.GetServerETagValueThread();
- ETagServer = ConnHandle.ETagValueResult();
- ETagDBPtr->UpdateETag(ContactFilename, ETagServer, ETagServer);
+ if (ETagGetResponse.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
+
+ ETagDBPtr->UpdateETag(ContactFilename, ETagGetResponse.EntityTag, ETagGetResponse.EntityTag);
iter->second = 4;
break;
while(KeepUpdating == TRUE){
+ COConnectResult ConnectResponse = ConnObjectIter->second->Connect(false);
+
bool ExitLoop = FALSE;
while (ExitLoop == FALSE){
- int ErrorCode = ConnHandle.SSLVerifyTest();
-
- if (ErrorCode != CURLE_OK){
+ if (ConnObjectIter->second->SSLVerify() == COSSL_UNABLETOVERIFY){
+
+ frmMainPtrGet->PauseAllTimers();
- 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.
-
- // Stop all the timers.
-
- frmMainPtrGet->PauseAllTimers();
-
- int SSLResult;
-
#if defined(__APPLE__)
+
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
+
+ ConnObjectIter->second->BypassSSLVerification(false);
+
+ int SSLResult = DisplayTrustPanel(ConnObjectIter->second->BuildSSLCollection(), AccountNameFriendly);
+
+ if (SSLResult != NSOKButton){
- // Bring up the trust panel and display the SSL certificate dialog.
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnObjectIter->second->BuildSSLCollection());
+ iter->second = 2;
+ break;
- SSLResult = DisplayTrustPanel(ConnHandle.GetTrustObject(), AccountNameFriendly);
+ } else {
- // Update the SSL account with the trust object.
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
- if (SSLResult != NSOKButton){
-
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetTrustObject());
- iter->second = 2;
- break;
-
- } else {
-
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
-
- }
-
+ }
+
#elif defined(__WIN32__)
- BOOL ModifiedCertificateData;
- CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(&ConnHandle, (HWND)frmMainPtrGet->GetHandle());
+ ConnObjectIter->second->BypassSSLVerification(true);
- if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)){
- wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
- }
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
- if (ModifiedCertificateData == FALSE){
+ ConnObjectIter->second->BypassSSLVerification(false);
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetCertificateContextPointer());
- iter->second = 2;
- break;
+ BOOL ModifiedCertificateData = false;
+ CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(ConnObjectIter->second, (HWND)frmMainPtrGet->GetHandle());
- } else {
+ if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)) {
+ wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+ }
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+ if (ModifiedCertificateData == false) {
- }
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnObjectIter->second->BuildSSLCollection());
+ iter->second = 2;
+ break;
+
+ } else {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
+
+ }
#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();
- // Setup the data to be sent in the wxPostEvent command.
+ bool *PauseMode = new bool;
+ QRNotif qrn;
- SSLInvalidCertNotifObj SSLICNProcData;
+ *PauseMode = TRUE;
+ qrn.QResponse = &SSLResult;
+ qrn.PausePtr = PauseMode;
- SSLCertCollection certcol = ConnHandle.GetSSLVerifyResults();
+ SSLICNProcData.CertCollection = certcol;
+ SSLICNProcData.QRNotifData = &qrn;
+ SSLICNProcData.AccountName = AccountNameFriendly;
- bool *PauseMode = new bool;
- QRNotif qrn;
+ wxCommandEvent event(INVALIDSSLCERTSTRING);
+ event.SetClientData(&SSLICNProcData);
+ wxPostEvent(frmMainPtrGet, event);
- *PauseMode = TRUE;
- qrn.QResponse = &SSLResult;
- qrn.PausePtr = PauseMode;
+ while (*PauseMode == TRUE){
+ //nanosleep(&n1, &n2);
+ SleepFor(250000000);
+ }
+
+ // Process the response from the user.
+
+ if (SSLResult == 1){
- SSLICNProcData.CertCollection = certcol;
- SSLICNProcData.QRNotifData = &qrn;
- SSLICNProcData.AccountName = AccountNameFriendly;
+ // Accept the Certificate.
+
+ UsingSSLBypass = true;
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult TestConnectionResult = ConnObjectIter->second->Connect(true);
+ WriteServerCertificate(AccountDir, certcol);
- wxCommandEvent event(INVALIDSSLCERT);
- event.SetClientData(&SSLICNProcData);
- wxPostEvent(frmMainPtrGet, event);
+ ConnObjectIter->second->BypassSSLVerification(false);
- /*timespec n1, n2;
-
- // Fall asleep until we get an response.
-
- n1.tv_sec = 0;
- n1.tv_nsec = 250000000L;*/
+ } else if (SSLResult == 2){
+
+ // Reject the certificate, abort the task and mark as failed.
+
+ iter->second = 2;
+ break;
- while (*PauseMode == TRUE){
- //nanosleep(&n1, &n2);
- SleepFor(250000000);
- }
+ }
+
+#endif
- // Process the response from the user.
+ frmMainPtrGet->ResumeAllTimers();
+ ExitLoop = true;
- 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.GetSSLVerifyResults());
- WriteServerCertificate(AccountDir, ConnHandle.GetSSLVerifyResults());
+ } else if (ConnectResponse == COCONNECT_AUTHFAIL){
+
+ ConnectResponse = ConnObjectIter->second->Connect(true);
+
+ if (ConnectResponse == COCONNECT_OK){
- } else if (SSLResult == 2){
+ ExitLoop = true;
+ break;
- // Reject the certificate, abort the task and mark as failed.
+ } else {
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetSSLVerifyResults());
- iter->second = 2;
- break;
+ ExitLoop = true;
+ iter->second = 2;
+ break;
- }
+ }
-#endif
+ } else if (ConnectResponse == COCONNECT_OK){
- // Resume all the timers.
+ ConnectResponse = ConnObjectIter->second->Connect(true);
- frmMainPtrGet->ResumeAllTimers();
- ExitLoop = TRUE;
+ ExitLoop = true;
+ break;
- } else {
+ } else {
- iter->second = 4;
- break;
+ ExitLoop = true;
+ iter->second = 2;
+ break;
- }
-
- } else {
-
- ExitLoop = TRUE;
-
}
}
#if defined(__APPLE__)
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject());
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
#elif defined(__WIN32__)
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
#else
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetSSLVerifyResults());
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
#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){
+ 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;
break;
}
wxArrayString vCardUpdateRemote;
wxArrayString vCardUpdateLog;
std::map<wxString,wxString> vCardETag;
- ContactListData ServerContactList;
std::map<wxString,vCardDownloadDataFileClass> vCardDownloadData;
- //wxArrayString vCardDownload;
- //std::map<wxString,wxString> vCardDownloadData;
// Get the list of vCard files locally.
std::map<wxString,ETagData> ETagDBData = ETagDBPtr->GetETagData();
- bool ExitLoop = FALSE;
-
- std::map<wxString,FileSyncData> *SCListData = NULL;
+ COConnectResult ConnectResponse = ConnObjectIter->second->Connect(false);
- while (ExitLoop == FALSE){
-
- // Check if any errors have occured whilst getting the data.
-
- int ErrorCode = ConnHandle.SSLVerifyTest();
-
- if (ErrorCode != CURLE_OK){
+ bool ExitLoop = FALSE;
- if (ErrorCode == CURLE_SSL_CACERT ||
- ErrorCode == CURLE_PEER_FAILED_VERIFICATION ||
- ErrorCode == CURLE_SSL_CONNECT_ERROR){
+ while (ExitLoop == FALSE){
- // Invalid SSL certificate so bring up a dialog to the user
- // explaining what has happened and the options available.
+ if (ConnObjectIter->second->SSLVerify() == COSSL_UNABLETOVERIFY){
+
+ frmMainPtrGet->PauseAllTimers();
+
+#if defined(__APPLE__)
+
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
+
+ ConnObjectIter->second->BypassSSLVerification(false);
+
+ int SSLResult = DisplayTrustPanel(ConnObjectIter->second->BuildSSLCollection(), AccountNameFriendly);
- // Stop all the timers.
+ if (SSLResult != NSOKButton){
- frmMainPtrGet->PauseAllTimers();
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnObjectIter->second->BuildSSLCollection());
+ iter->second = 2;
+ break;
+
+ } else {
+
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
+
+ }
- int SSLResult;
+#elif defined(__WIN32__)
-#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());
-
- }
+ ConnObjectIter->second->BypassSSLVerification(true);
-#elif defined(__WIN32__)
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
- BOOL ModifiedCertificateData;
- CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(&ConnHandle, (HWND)frmMainPtrGet->GetHandle());
+ ConnObjectIter->second->BypassSSLVerification(false);
- if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)){
- wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
- }
+ BOOL ModifiedCertificateData = false;
+ CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(ConnObjectIter->second, (HWND)frmMainPtrGet->GetHandle());
- if (ModifiedCertificateData == FALSE){
+ if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)) {
+ wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog"));
+ }
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetCertificateContextPointer());
- iter->second = 2;
- break;
+ if (ModifiedCertificateData == false) {
- } else {
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnObjectIter->second->BuildSSLCollection());
+ iter->second = 2;
+ break;
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+ } else {
- }
-#else
-
- // Setup the data to be sent in the wxPostEvent command.
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
- SSLInvalidCertNotifObj SSLICNProcData;
+ }
- SSLCertCollection certcol = ConnHandle.GetSSLVerifyResults();
+#else
+
+ bool UsingSSLBypass = false;
+ int SSLResult = 0;
+
+ // Connect again and fetch SSL certificate information.
+
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false);
- bool *PauseMode = new bool;
- QRNotif qrn;
+ ConnObjectIter->second->BypassSSLVerification(false);
- *PauseMode = TRUE;
- qrn.QResponse = &SSLResult;
- qrn.PausePtr = PauseMode;
-
- SSLICNProcData.CertCollection = certcol;
- SSLICNProcData.QRNotifData = &qrn;
- SSLICNProcData.AccountName = AccountNameFriendly;
+ SSLInvalidCertNotifObjString SSLICNProcData;
- wxCommandEvent event(INVALIDSSLCERT);
- event.SetClientData(&SSLICNProcData);
- wxPostEvent(frmMainPtrGet, event);
-
- while (*PauseMode == TRUE){
- //nanosleep(&n1, &n2);
- SleepFor(250000000);
- }
+ 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.
+ // Process the response from the user.
- if (SSLResult == 1){
+ if (SSLResult == 1){
- // Accept the certificate. Write the certificate into the account
- // directory (as server.crt) - will overwrite old certificate.
+ // Accept the Certificate.
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetSSLVerifyResults());
- WriteServerCertificate(AccountDir, ConnHandle.GetSSLVerifyResults());
+ UsingSSLBypass = true;
+ ConnObjectIter->second->BypassSSLVerification(true);
+
+ COConnectResult TestConnectionResult = ConnObjectIter->second->Connect(true);
+ WriteServerCertificate(AccountDir, certcol);
- } else if (SSLResult == 2){
+ ConnObjectIter->second->BypassSSLVerification(false);
- // Reject the certificate, abort the task and mark as failed.
+ } else if (SSLResult == 2){
+
+ // Reject the certificate, abort the task and mark as failed.
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, ConnHandle.GetSSLVerifyResults());
- iter->second = 2;
- break;
+ iter->second = 2;
+ break;
- }
-
+ }
+
#endif
- // Resume all the timers.
+ frmMainPtrGet->ResumeAllTimers();
+ ExitLoop = true;
+
+ } else if (ConnectResponse == COCONNECT_AUTHFAIL){
+
+ ConnectResponse = ConnObjectIter->second->Connect(true);
+
+ if (ConnectResponse == COCONNECT_OK){
+
+ ExitLoop = true;
+ break;
- frmMainPtrGet->ResumeAllTimers();
- ExitLoop = TRUE;
-
} else {
-
- iter->second = 4;
+
+ ExitLoop = true;
+ iter->second = 2;
break;
+
+ }
+
+ } else if (ConnectResponse == COCONNECT_OK){
+ ConnectResponse = ConnObjectIter->second->Connect(true);
+
+ if (ConnectResponse == COCONNECT_OK){
+
+ ExitLoop = true;
+ break;
+
+ } else {
+
+ ExitLoop = true;
+ iter->second = 2;
+ break;
+
}
-
+
+ ExitLoop = true;
+ break;
+
} else {
-
- ExitLoop = TRUE;
-
+
+ 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());
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
#elif defined(__WIN32__)
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer());
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
#else
- frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetSSLVerifyResults());
+ frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnObjectIter->second->BuildSSLCollection());
#endif
+
+ if (iter->second == 2 || iter->second == 3 || iter->second == 4){
+ break;
+ }
// Look in directory and see which vCards to add and delete
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;
+ COContactList ServerContactList2 = ConnObjectIter->second->GetContactList(SyncTokenLoad.ToStdString());
// Process the server data.
- if (SCListData != NULL){
-
- for (std::map<wxString, FileSyncData>::iterator fsiter = SCListData->begin();
- fsiter != SCListData->end(); fsiter++){
-
- // Check the mode of the file before adding.
-
- // Get the HTTP status of the file from the list.
-
- FileSyncData fsd = fsiter->second;
-
- if (fsd.DataFlag == 1){
-
- // Added or modified contact.
-
- //vCardAdd.Add(fsiter->first, 1);
-
- vCardDownloadDataFileClass vCardNewData;
- vCardNewData.DataType = 0;
- vCardDownloadData.insert(std::make_pair(fsiter->first, vCardNewData));
-
- //} else if (fsd.DataFlag == 1){
-
- // Contact has been modified on the server.
-
- // vCardUpdateLocal.Add(fsiter->first, 1);
-
- }
- else if (fsd.DataFlag == 2){
-
- // Contact has been deleted.
-
- vCardDelete.Add(fsiter->first, 1);
-
- }
-
+ for (std::vector<COContactData>::iterator ContactInfo = ServerContactList2.ListData.begin();
+ ContactInfo != ServerContactList2.ListData.end(); ContactInfo++){
+
+ if (ContactInfo->Status == COCS_UPDATED){
+
+ vCardDownloadDataFileClass vCardNewData;
+ vCardNewData.DataType = 0;
+ vCardDownloadData.insert(std::make_pair(ContactInfo->Location, vCardNewData));
+
+ } else if (ContactInfo->Status == COCS_DELETED){
+
+ vCardDelete.Add(ContactInfo->Location, 1);
+
}
-
+
}
// Look for vCards that are missing but in the ETagDB.
// needs to updated remotely and which needs to be
// updated locally.
- for (std::map<wxString,FileSyncData>::iterator srviter = SCListData->begin();
- srviter != SCListData->end(); srviter++){
-
- if (ETagDBData.find(srviter->first) == ETagDBData.end()){
+ for (std::vector<COContactData>::iterator ContactInfo = ServerContactList2.ListData.begin();
+ ContactInfo != ServerContactList2.ListData.end(); ContactInfo++){
+
+ if (ETagDBData.find(ContactInfo->Location) == ETagDBData.end()){
continue;
}
-
- std::map<wxString,ETagData>::iterator lociter = ETagDBData.find(srviter->first);
-
+
+ std::map<wxString,ETagData>::iterator lociter = ETagDBData.find(ContactInfo->Location);
+
ETagData etd = lociter->second;
- FileSyncData fsd = srviter->second;
-
- wxString ETagSrv = fsd.ETagData;
+
+ wxString ETagSrv = ContactInfo->Data;
// Check if the local ETag value has 'DELETED' set and skip
// checking this file if it does.
vCard34Conv vCard34Obj;
- wxString ServerContactData;
wxString FullFilename;
vCard ClientData;
vCard ConvertedV4Data;
+ std::string ServerContactDataString;
+ wxString ServerContactData;
+
// Conflict. Bring up conflict resolution dialog.
// Get the server contact data for comparison.
- ConnHandle.SetServerFilename(srviter->first);
- ConnHandle.GetServerContactData();
- ServerContactData = ConnHandle.GetPageData();
+ ConnObjectIter->second->GetContact(ContactInfo->Location, &ServerContactDataString);
+ ServerContactData = wxString::FromUTF8(ServerContactDataString.c_str());
- FullFilename = CreateFilenamePath(AccountDirFinal, srviter->first);
+ FullFilename = CreateFilenamePath(AccountDirFinal, ContactInfo->Location);
// Convert it to v4.
// Decided to use client version.
- vCardUpdateLocal.Remove(srviter->first);
- vCardUpdateRemote.Add(srviter->first, 1);
+ vCardUpdateLocal.Remove(ContactInfo->Location);
+ vCardUpdateRemote.Add(ContactInfo->Location, 1);
} else if (ConflictResult == 2){
ConvertedV4Data.WriteFile(FullFilename);
- vCardDownloadData.insert(std::make_pair(srviter->first, vCardNewData));
+ vCardDownloadData.insert(std::make_pair(ContactInfo->Location, vCardNewData));
// Send vCard to the server.
- vCardUpdateRemote.Add(srviter->first, 1);
+ vCardUpdateRemote.Add(ContactInfo->Location, 1);
}
if (etd.ETagOrigValue != ETagSrv){
- vCardUpdateLocal.Add(srviter->first, 1);
+ vCardUpdateLocal.Add(ContactInfo->Location, 1);
}
}
-
+
}
// Process the vCards that need to be downloaded and added/overwritten.
// Grab the file from the server and write the contact out.
vCard34Conv vCard34Obj;
-
- ConnHandle.SetServerFilename(additer->first);
- ConnHandle.GetServerContactData();
- vCardInputData = ConnHandle.GetPageData();
+
+ wxString ServerContactData;
+ std::string ServerContactDataString;
+
+ // Conflict. Bring up conflict resolution dialog.
+
+ // Get the server contact data for comparison.
+
+ ConnObjectIter->second->GetContact(additer->first.ToStdString(), &ServerContactDataString);
+ vCardInputData = wxString::FromUTF8(ServerContactDataString.c_str());
vCard34Obj.ConvertToV4(&vCardInputData, &ConvertedV4Data);
ConvertedV4Data.WriteFile(vCardFilenameFinal);
- // Update the ETagDB.
-
- //vCardFile.Open(vCardFilenameFinal, wxT("w"));
-
- //if (vCardFile.IsOpened()){
-
- // vCardFile.Write(vCardOutputData, wxConvAuto());
- // vCardFile.Close();
-
- //}
-
// Get the server ETag.
wxString ServerETag;
- ConnHandle.GetServerETagValueThread();
- ServerETag = ConnHandle.ETagValueResult();
-
+
+ COServerResponse ServerEntityTag = ConnObjectIter->second->GetServerEntityTagValue(additer->first.ToStdString());
+
+ if (ServerEntityTag.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
+
+ ServerETag = wxString::FromUTF8(ServerEntityTag.EntityTag.c_str());
+
// Add to the ETag Database.
ETagDBPtr->AddETag(additer->first, ServerETag, ServerETag);
// Update the ETagDB.
wxString ServerETag;
- ConnHandle.GetServerETagValueThread();
- ServerETag = ConnHandle.ETagValueResult();
+
+ COServerResponse ServerEntityTag = ConnObjectIter->second->GetServerEntityTagValue(additer->first.ToStdString());
+
+ if (ServerEntityTag.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
+
+ ServerETag = wxString::FromUTF8(ServerEntityTag.EntityTag.c_str());
// Add to the ETag Database.
}
}
+
+ // Check if any errors occured before continuing.
+
+ if (iter->second != 1){
+ break;
+ }
// Look for vCard files which aren't in the ETagDB.
if (ETag == ETagOriginal && ETagDBPtr->ETagExists(vCardAdd[vi])){
// Compare the ETag with the Server ETag.
-
- ConnHandle.SetServerFilename(vCardAdd[vi]);
- ConnHandle.GetServerETagValueThread();
- ETagServer = ConnHandle.ETagValueResult();
+
+ COServerResponse ServerEntityTag = ConnObjectIter->second->GetServerEntityTagValue(vCardAdd[vi].ToStdString());
+
+ if (ServerEntityTag.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
+
+ // TODO: Continue from here!
+
+ ETagServer = wxString::FromUTF8(ServerEntityTag.EntityTag.c_str());
if (ETagOriginal != ETagServer){
vCard34Conv vCard34Obj;
wxString ServerContactData;
+ std::string ServerContactDataString;
vCard ClientData;
vCard ConvertedV4Data;
// Load the client data from the filename given.
-
- ConnHandle.GetServerContactData();
- ServerContactData = ConnHandle.GetPageData();
+
+ COServerResponse GetContactResponse = ConnObjectIter->second->GetContact(vCardAdd[vi].ToStdString(), &ServerContactDataString);
+
+ if (GetContactResponse.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
+
+ ServerContactData = wxString::FromUTF8(ServerContactDataString.c_str());
// Process v3 version into v4 version.
vCardProcData.vCardServerData = &ConvertedV4Data;
ClientData.LoadFile(FullFilename);
- //ContactConflictEvent event(ContactConflictCmdEnv);
- //event.SetData(ContactFilename, Moo1, Moo2);
-
- //wxPostEvent(frmMainPtrGet, event);
-
// Setup Conflict Resolution Dialog.
// Fetch Data from Server and convert.
delete PauseMode;
PauseMode = NULL;
- //intResult = frmMainPtrGet->ShowConflictDialog(&Moo1, &Moo2);
-
if (ConflictResult == 0){
// Decide Later.
// Decided to use client version.
- ConnHandle.ProcessData();
+ COServerResponse EditContactResponse = ConnObjectIter->second->EditContact(vCardAdd[vi].ToStdString(), ClientData.WriteString().ToStdString());
+ if (EditContactResponse.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
+
iter->second = 4;
} else if (ConflictResult == 2){
wxString wxSFilename = CreateFilenamePath(AccountDirFinal, vCardAdd[vi]);
wxString wxSCardData;
wxString TaskData;
- //wxString TaskURL;
// Load the data from the file.
vCard34Conv vCard34Obj;
vCard34Obj.ConvertToV3(wxSFilename, &TaskData);
-
- // Setup the URL address.
-
- //TaskURL = StringTaskDetailIter->second + wxT("/") + vCardAdd[vi];
// Upload the data to the server.
-
- ConnHandle.SetUploadMode(TRUE);
- ConnHandle.SetupData(wxT("PUT"), vCardAdd[vi], TaskData);
- ConnHandle.ProcessData();
+
+ COServerResponse AddContactResponse = ConnObjectIter->second->AddContact(vCardAdd[vi].ToStdString(), TaskData.ToStdString());
+ if (AddContactResponse.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
+
// Get the Server ETag and put it in the ETag database.
-
- ConnHandle.SetServerFilename(vCardAdd[vi]);
- ConnHandle.GetServerETagValueThread();
- ETagServer = ConnHandle.ETagValueResult();
+
+ COServerResponse EntityTagResponse = ConnObjectIter->second->GetServerEntityTagValue(vCardAdd[vi].ToStdString());
+
+ if (EntityTagResponse.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
+
+ ETagServer = wxString::FromUTF8(EntityTagResponse.EntityTag.c_str());
ETagDBPtr->AddETag(vCardAdd[vi], ETagServer, ETagServer);
frmMain *frmMainPtrGet = (frmMain *)frmMainPtr;
- //ContactConflictEvent event(ContactConflictCmdEnv);
- //event.SetData(ContactFilename, Moo1, Moo2);
-
vCard34Conv vCard34Obj;
+ std::string ServerContactDataString;
wxString ServerContactData;
vCard ClientData;
vCard ConvertedV4Data;
// Load the client data from the filename given.
- ConnHandle.GetServerContactData();
- ServerContactData = ConnHandle.GetPageData();
+ COServerResponse GetContactResponse = ConnObjectIter->second->GetContact(vCardAdd[vi].ToStdString(), &ServerContactDataString);
+
+ if (GetContactResponse.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
+
+ ServerContactData = wxString::FromUTF8(ServerContactDataString.c_str());
+
ClientData.LoadFile(FullFilename);
// Process v3 version into v4 version.
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED);
event.SetClientData(&vCardProcData);
wxPostEvent(frmMainPtrGet, event);
-
+
while (*PauseMode == TRUE){
- //nanosleep(&n1, &n2);
SleepFor(250000000);
}
delete PauseMode;
PauseMode = NULL;
- //intResult = frmMainPtrGet->ShowConflictDialog(&Moo1, &Moo2);
-
if (ConflictResult == 0){
// Decide Later.
// Decided to use client version.
- ConnHandle.ProcessData();
- //ETagServer = CardDAVIter->second.GetServerETagValueThread();
- //ETagDBPtr->UpdateETag(ContactFilename, ETagServer, ETagServer);
-
+ COServerResponse EditContactResponse = ConnObjectIter->second->EditContact(vCardAdd[vi].ToStdString(), ClientData.WriteString().ToStdString());
+
+ if (EditContactResponse.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
+
iter->second = 4;
} else if (ConflictResult == 2){
wxString wxSFilename = CreateFilenamePath(AccountDirFinal, vCardAdd[vi]);
wxString wxSCardData;
wxString TaskData;
- //wxString TaskURL;
// Load the data from the file.
vCard34Conv vCard34Obj;
vCard34Obj.ConvertToV3(wxSFilename, &TaskData);
-
- // Setup the URL address.
-
- //TaskURL = StringTaskDetailIter->second + wxT("/") + vCardAdd[vi];
// Upload the data to the server.
-
- ConnHandle.SetUploadMode(TRUE);
- ConnHandle.SetupData(wxT("PUT"), vCardAdd[vi], TaskData);
- ConnHandle.ProcessData();
-
+
+ COServerResponse AddContactResponse = ConnObjectIter->second->AddContact(vCardAdd[vi].ToStdString(), TaskData.ToStdString());
+
+ if (AddContactResponse.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
+
// Get the Server ETag and put it in the ETag database.
- ConnHandle.SetServerFilename(vCardAdd[vi]);
- ConnHandle.GetServerETagValueThread();
- ETagServer = ConnHandle.ETagValueResult();
-
+ COServerResponse EntityTagResponse = ConnObjectIter->second->GetServerEntityTagValue(vCardAdd[vi].ToStdString());
+ if (EntityTagResponse.RequestResult != COREQUEST_OK){
+ iter->second = 2;
+ break;
+ }
+
ETagDBPtr->AddETag(vCardAdd[vi], ETagServer, ETagServer);
}
}
+ if (iter->second != 1){
+ break;
+ }
+
// Process the vCards to delete locally.
for (int vi = 0; vi < vCardDelete.GetCount(); vi++){
if (deliter->second == wxT("DELETED")){
- ConnHandle.SetUploadMode(FALSE);
- ConnHandle.SetupData(wxT("DELETE"), deliter->first, wxT(""));
- ConnHandle.ProcessDataThread();
+ ConnObjectIter->second->DeleteContact(deliter->first.ToStdString());
// Delete the ETag as the file has now been deleted.
}
for (std::list<wxString>::iterator removeetagiter = DeleteList.begin();
- removeetagiter != DeleteList.end(); removeetagiter++){
+ removeetagiter != DeleteList.end(); removeetagiter++){
ETagDBPtr->RemoveETag(*removeetagiter);
// Write out the update server sync token.
- wxString ServerSyncToken = ServerContactList.SyncToken;
+ wxString ServerSyncToken = wxString::FromUTF8(ServerContactList2.SyncToken.c_str());
ServerSyncToken.Trim();
KeepUpdating = FALSE;
}
-
+
}
-
+
// Mark as completed.
-
+
wxString AccountNameFinal;
AccountNameFinal = PrefData.accounts.GetAccountDirectory(AccountID);
AccountNameFinal.Append(wxT(".carddav"));
wxCommandEvent reloadevent(RELOADCONTACTLIST);
reloadevent.SetString(AccountNameFinal);
wxPostEvent(this->GetParent(), reloadevent);
-
+
iter->second = 4;
continue;
} else {
// Update the data to the server.
-
- ConnHandle.ProcessData();
+
iter->second = 4;
continue;
}
- /*timespec n1, n2;
-
- n1.tv_sec = 0;
- n1.tv_nsec = 250000000L;*/
-
while (iter->second == 1){
- SleepFor(250000000);
- //nanosleep(&n1, &n2);
+ SleepFor(125000000);
}
- if ((iter->second == 4 && TypeIter->second == 0) ||
- (iter->second == 8 && TypeIter->second == 0)){
-
- AccountDir = StringAccountIter->second;
- ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
-
- ConnHandle.GetServerETagValueThread();
- ETagServer = ConnHandle.ETagValueResult();
- ETagDBPtr->UpdateETag(ContactFilename, ETagServer, ETagServer);
-
- }
-
- if ((iter->second == 4 && TypeIter->second == 1) ||
- (iter->second == 8 && TypeIter->second == 1)){
-
- AccountDir = StringAccountIter->second;
- ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir);
-
- ConnHandle.GetServerETagValueThread();
- ETagServer = ConnHandle.ETagValueResult();
- ETagDBPtr->UpdateETag(ContactFilename, ETagServer, ETagServer);
-
- }
-
break;
}
wxCommandEvent eventp(ACTMGR_STARTTIMER);
wxPostEvent(this, eventp);
-
- //AnimationTimer.StartAnimation();
- //ActListProcTimer.Start();
}
wxCommandEvent event(ACTMGR_STARTPROCESSTIMER);
wxPostEvent(this, event);
- //ActProcessTimer.Start();
-
}
void frmActivityMgr::ProcessTasks()
}
+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<int, SSLCertDataString>::iterator SSLCDIter = SSLCertInc.SSLCollection.find(0);
+ std::multimap<string,string>::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);
lstActivity->SetItem(actmgrudata->ItemIndex, 2, actmgrudata->ItemLabel);
- /*if (!actmgrudata->ItemDes.IsEmpty()){
- lstActivity->SetItem(actmgrudata->ItemIndex, 0, actmgrudata->ItemDes);
- }*/
-
delete actmgrudata;
actmgrudata = NULL;
}
-}
\ No newline at end of file
+}