From 2c8998278759b5bf6fc3bcf75afd289c214b6c84 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sat, 10 Sep 2016 18:39:07 +0100 Subject: [PATCH] Removed references of CardDAV and delete ConnectionObject when finished --- source/actmgr/frmActivityMgr-tasks.cpp | 4 -- source/actmgr/frmActivityMgr.cpp | 76 ++++++++++++++++++++++++-- source/actmgr/frmActivityMgr.h | 1 - source/common/timers.cpp | 17 +++++- source/common/timers.h | 28 +++++----- 5 files changed, 98 insertions(+), 28 deletions(-) diff --git a/source/actmgr/frmActivityMgr-tasks.cpp b/source/actmgr/frmActivityMgr-tasks.cpp index 2efca05..842598d 100644 --- a/source/actmgr/frmActivityMgr-tasks.cpp +++ b/source/actmgr/frmActivityMgr-tasks.cpp @@ -293,10 +293,6 @@ void frmActivityMgr::RetryTask( wxCommandEvent& event ){ return; } - std::map::iterator CDAVter; - - CDAVter = ActivityListConn.find(intSelectedData); - // Restart the task. //CDAVter->second.Abort(); diff --git a/source/actmgr/frmActivityMgr.cpp b/source/actmgr/frmActivityMgr.cpp index 40ab583..ec4700c 100644 --- a/source/actmgr/frmActivityMgr.cpp +++ b/source/actmgr/frmActivityMgr.cpp @@ -80,7 +80,7 @@ frmActivityMgrADT( parent ) ActListProcTimer.SetupPointers(&ActivityList, &ActivityListIndex, &ActivityListTaskDetail, &TasksActive, lstActivity, lblDetails, GauProgress, this, &AnimationTimer, - &ActProcessTimer, &ActivityListFinDate, &ActivityListConn); + &ActProcessTimer, &ActivityListFinDate, &ActivityListConnObject); AnimationTimer.SetBitmap(bmpActivity); AnimationTimer.SetSleepBitmap(&SleepBitmap); @@ -966,7 +966,6 @@ void frmActivityMgr::ProcessTasksThread() wxArrayString vCardUpdateRemote; wxArrayString vCardUpdateLog; std::map vCardETag; - ContactListData ServerContactList; std::map vCardDownloadData; @@ -1017,8 +1016,6 @@ void frmActivityMgr::ProcessTasksThread() COConnectResult ConnectResponse = ConnObjectIter->second->Connect(false); bool ExitLoop = FALSE; - - std::map *SCListData = NULL; while (ExitLoop == FALSE){ @@ -1395,6 +1392,11 @@ void frmActivityMgr::ProcessTasksThread() 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. @@ -1423,6 +1425,11 @@ void frmActivityMgr::ProcessTasksThread() 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. @@ -1431,6 +1438,12 @@ void frmActivityMgr::ProcessTasksThread() } } + + // Check if any errors occured before continuing. + + if (iter->second != 1){ + break; + } // Look for vCard files which aren't in the ETagDB. @@ -1489,6 +1502,13 @@ void frmActivityMgr::ProcessTasksThread() 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){ @@ -1510,6 +1530,11 @@ void frmActivityMgr::ProcessTasksThread() 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. @@ -1561,6 +1586,11 @@ void frmActivityMgr::ProcessTasksThread() 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){ @@ -1605,10 +1635,20 @@ void frmActivityMgr::ProcessTasksThread() 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. 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); @@ -1636,6 +1676,11 @@ void frmActivityMgr::ProcessTasksThread() 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); @@ -1682,7 +1727,12 @@ void frmActivityMgr::ProcessTasksThread() // Decided to use client version. 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){ @@ -1726,11 +1776,21 @@ void frmActivityMgr::ProcessTasksThread() // Upload the data to the server. 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. COServerResponse EntityTagResponse = ConnObjectIter->second->GetServerEntityTagValue(vCardAdd[vi].ToStdString()); + if (EntityTagResponse.RequestResult != COREQUEST_OK){ + iter->second = 2; + break; + } + ETagDBPtr->AddETag(vCardAdd[vi], ETagServer, ETagServer); } @@ -1739,6 +1799,10 @@ void frmActivityMgr::ProcessTasksThread() } + if (iter->second != 1){ + break; + } + // Process the vCards to delete locally. for (int vi = 0; vi < vCardDelete.GetCount(); vi++){ diff --git a/source/actmgr/frmActivityMgr.h b/source/actmgr/frmActivityMgr.h index 2c6ffc6..9947ea4 100644 --- a/source/actmgr/frmActivityMgr.h +++ b/source/actmgr/frmActivityMgr.h @@ -108,7 +108,6 @@ class frmActivityMgr : public frmActivityMgrADT std::map ActivityListAccount; std::map ActivityListFilename; std::map ActivityListFullFilename; - std::map ActivityListConn; std::map ActivityListConnObject; std::map ActivityListAccSettings; std::map ActivityListETag; diff --git a/source/common/timers.cpp b/source/common/timers.cpp index 88bbb3e..4ba3e94 100644 --- a/source/common/timers.cpp +++ b/source/common/timers.cpp @@ -297,7 +297,7 @@ void wxActListProcTimer::Notify(){ ueventdata->ItemLabel = _("Stopped"); wxPostEvent(static_cast(ActMgrPtr), uevent); - iter->second = 5; + iter->second = 6; } else if (iter->second == 4){ @@ -309,6 +309,17 @@ void wxActListProcTimer::Notify(){ } + // Delete the connection object if finished. + + if (iter->second > 4){ + + std::map::iterator ConnObjectIter = ActListConnObjectsPtr->find(iter->first); + + delete ConnObjectIter->second; + ConnObjectIter->second = nullptr; + + } + // Insert a finish date. wxDateTime adt; @@ -345,7 +356,7 @@ void wxActListProcTimer::SetupPointers(std::map *ActList, std::map *ActListDetail, bool *TasksActive, wxListCtrl *lstActivity, wxStaticText *lblDetails, wxGauge *GauProgress, void *ActMgr, wxActTimer *ActTimer, wxActProcessTimer *ActProcessTimer, - std::map *ActListFinDT, std::map *ActListConn){ + std::map *ActListFinDT, std::map *ActListConnObjects){ // Setup the pointers for wxActListProcTimer. @@ -360,7 +371,7 @@ void wxActListProcTimer::SetupPointers(std::map *ActList, std::map #include "../actmgr/frmActivityMgr.h" #include "../contacteditor/frmContactEditor.h" +#include "../connobject/ConnectionObject.h" #include "etag.h" #ifndef TIMERS_H @@ -30,7 +31,6 @@ struct ETagDB; struct frmContactEditor; -struct CardDAV; class wxActTimer : public wxTimer { @@ -73,20 +73,20 @@ class wxActListProcTimer : public wxTimer { private: - std::map *ActListPtr; - std::map *ActListUIPtr; - std::map *ActListDetailPtr; - std::map *ActListConnPtr; - wxListCtrl *lstActivityPtr; - wxStaticText *lblDetailsPtr; - bool *TasksActivePtr; - wxGauge *GauProgressPtr; - void *ActMgrPtr; + std::map *ActListPtr = nullptr; + std::map *ActListUIPtr = nullptr; + std::map *ActListDetailPtr = nullptr; + wxListCtrl *lstActivityPtr = nullptr; + wxStaticText *lblDetailsPtr = nullptr; + bool *TasksActivePtr = nullptr; + wxGauge *GauProgressPtr = nullptr; + void *ActMgrPtr = nullptr; int intActivityTotal = 0; int intActivityCompleted = 0; - wxActTimer *ActTimerPtr; - wxActProcessTimer *ActProcessTimerPtr; - std::map *ActListFinDTPtr; + wxActTimer *ActTimerPtr = nullptr; + wxActProcessTimer *ActProcessTimerPtr = nullptr; + std::map *ActListFinDTPtr = nullptr; + std::map *ActListConnObjectsPtr = nullptr; bool ClearupProcessed = FALSE; public: wxActListProcTimer():wxTimer() @@ -97,7 +97,7 @@ public: std::map *ActListDetail, bool *TasksActive, wxListCtrl *lstActivity, wxStaticText *lblDetails, wxGauge *GauProgress, void *ActMgr, wxActTimer *ActTimer, wxActProcessTimer *ActProcessTimer, - std::map *ActListFinDT, std::map *ActListConn); + std::map *ActListFinDT, std::map *ActListConnObjects); void EnableClearup(); }; -- 2.39.5