From: Steve Brokenshire Date: Mon, 30 Nov 2015 10:31:18 +0000 (+0000) Subject: Replaced CardDAV with CardDAV* in the activity manager, improving memory usage. X-Git-Tag: release-0.06~20 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=d1f14e9baf9a6201bcae96e13b0b25bfe6d823f4;p=xestiaab%2F.git Replaced CardDAV with CardDAV* in the activity manager, improving memory usage. --- diff --git a/source/common/timers.cpp b/source/common/timers.cpp index 3f0b181..c3ed546 100644 --- a/source/common/timers.cpp +++ b/source/common/timers.cpp @@ -313,6 +313,12 @@ void wxActListProcTimer::Notify(){ ActListFinDTPtr->insert(std::make_pair(iter->first, adt)); + // Delete the connection object. + + std::map::iterator ConnObject = ActListConnPtr->find(iter->first); + delete ConnObject->second; + ConnObject->second = NULL; + } if (ClearupProcessed == TRUE){ @@ -342,7 +348,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 *ActListFinDT, std::map *ActListConn){ ActListPtr = ActList; ActListUIPtr = ActListUI; @@ -355,6 +361,7 @@ void wxActListProcTimer::SetupPointers(std::map *ActList, std::map *ActListPtr; std::map *ActListUIPtr; std::map *ActListDetailPtr; + std::map *ActListConnPtr; wxListCtrl *lstActivityPtr; wxStaticText *lblDetailsPtr; bool *TasksActivePtr; @@ -95,7 +96,7 @@ public: std::map *ActListDetail, bool *TasksActive, wxListCtrl *lstActivity, wxStaticText *lblDetails, wxGauge *GauProgress, void *ActMgr, wxActTimer *ActTimer, wxActProcessTimer *ActProcessTimer, - std::map *ActListFinDT); + std::map *ActListFinDT, std::map *ActListConn); void EnableClearup(); }; diff --git a/source/frmActivityMgr.cpp b/source/frmActivityMgr.cpp index f26e00f..69ae3c7 100644 --- a/source/frmActivityMgr.cpp +++ b/source/frmActivityMgr.cpp @@ -82,7 +82,7 @@ frmActivityMgrADT( parent ) ActListProcTimer.SetupPointers(&ActivityList, &ActivityListIndex, &ActivityListTaskDetail, &TasksActive, lstActivity, lblDetails, GauProgress, this, &AnimationTimer, - &ActProcessTimer, &ActivityListFinDate); + &ActProcessTimer, &ActivityListFinDate, &ActivityListConn); AnimationTimer.SetBitmap(bmpActivity); AnimationTimer.SetSleepBitmap(&SleepBitmap); @@ -180,7 +180,7 @@ int frmActivityMgr::AddTask(int TaskType, wxString TaskDetail, wxString TaskAcco wxListItem coldata; long itemindex = -1; - CardDAV CardDAVConn; + CardDAV* CardDAVConn = new CardDAV; coldata.SetId(ActivityTaskID); coldata.SetData(ActivityTaskID); @@ -233,9 +233,9 @@ int frmActivityMgr::AddTask(int TaskType, wxString TaskDetail, wxString TaskAcco } - CardDAVConn.SetupConnection(AccountAddress, AccountPort, AccountUsername, AccountPassword, AccountSSL, AccountPrefix, AccountDir); - CardDAVConn.SetupVariables(&ActivityList, ActivityTaskID); - CardDAVConn.SetupResultBools(&BlankBool, &BlankBool); + CardDAVConn->SetupConnection(AccountAddress, AccountPort, AccountUsername, AccountPassword, AccountSSL, AccountPrefix, AccountDir); + CardDAVConn->SetupVariables(&ActivityList, ActivityTaskID); + CardDAVConn->SetupResultBools(&BlankBool, &BlankBool); // TaskType: // 0 - Add a contact. @@ -251,8 +251,8 @@ int frmActivityMgr::AddTask(int TaskType, wxString TaskDetail, wxString TaskAcco lstActivity->SetItem(itemindex, 1, AccountName); lstActivity->SetItem(itemindex, 2, _("Queued")); - CardDAVConn.SetUploadMode(TRUE); - CardDAVConn.SetupData(wxT("PUT"), TaskURL, TaskData); + CardDAVConn->SetUploadMode(TRUE); + CardDAVConn->SetupData(wxT("PUT"), TaskURL, TaskData); // Setup all of the task details. @@ -279,9 +279,9 @@ int frmActivityMgr::AddTask(int TaskType, wxString TaskDetail, wxString TaskAcco lstActivity->SetItem(itemindex, 1, AccountName); lstActivity->SetItem(itemindex, 2, _("Queued")); - CardDAVConn.SetUploadMode(TRUE); - CardDAVConn.SetupData(wxT("PUT"), TaskURL, TaskData); - CardDAVConn.SetEditMode(TRUE); + CardDAVConn->SetUploadMode(TRUE); + CardDAVConn->SetupData(wxT("PUT"), TaskURL, TaskData); + CardDAVConn->SetEditMode(TRUE); ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir); @@ -378,11 +378,11 @@ void frmActivityMgr::StopTask( wxCommandEvent& event ){ return; } - std::map::iterator CDAVter; + std::map::iterator CDAVter; CDAVter = ActivityListConn.find(intSelectedData); - CDAVter->second.Abort(); + CDAVter->second->Abort(); lstActivity->SetItem(longSelected, 2, _("Stopped")); @@ -407,11 +407,11 @@ void frmActivityMgr::StopAllTasks( wxCommandEvent& event ){ return; } - std::map::iterator CDAVter; + std::map::iterator CDAVter; CDAVter = ActivityListConn.find(intSelectedData); - CDAVter->second.Abort(); + CDAVter->second->Abort(); lstActivity->SetItem(longSelected, 2, _("Stopped")); AnimationTimer.StopAnimation(); @@ -437,7 +437,7 @@ void frmActivityMgr::RetryTask( wxCommandEvent& event ){ return; } - std::map::iterator CDAVter; + std::map::iterator CDAVter; CDAVter = ActivityListConn.find(intSelectedData); @@ -498,7 +498,7 @@ void frmActivityMgr::ProcessTasksThread() std::map::iterator StringTaskDetailIter; std::map::iterator StringETagIter; std::map::iterator StringETagOrigIter; - std::map::iterator CardDAVIter; + std::map::iterator CardDAVIter; std::map::iterator LongIter; bool TasksFoundProc = FALSE; wxString TaskDetail; @@ -549,8 +549,8 @@ void frmActivityMgr::ProcessTasksThread() iter->second = 1; if (TypeIter->second == 1){ - CardDAVIter->second.GetServerETagValueThread(); - ETagServer = CardDAVIter->second.ETagValueResult(); + CardDAVIter->second->GetServerETagValueThread(); + ETagServer = CardDAVIter->second->ETagValueResult(); } // Compare the ETags and work out if a conflict has occured. @@ -588,8 +588,8 @@ void frmActivityMgr::ProcessTasksThread() // Load the client data from the filename given. - CardDAVIter->second.GetServerContactData(); - ServerContactData = CardDAVIter->second.GetPageData(); + CardDAVIter->second->GetServerContactData(); + ServerContactData = CardDAVIter->second->GetPageData(); // Process v3 version into v4 version. @@ -650,7 +650,7 @@ void frmActivityMgr::ProcessTasksThread() // Decided to use client version. - CardDAVIter->second.ProcessData(); + CardDAVIter->second->ProcessData(); iter->second = 4; @@ -670,7 +670,7 @@ void frmActivityMgr::ProcessTasksThread() // Update the data to the server. - CardDAVIter->second.ProcessData(); + CardDAVIter->second->ProcessData(); } @@ -695,8 +695,8 @@ void frmActivityMgr::ProcessTasksThread() // Load the client data from the filename given. - CardDAVIter->second.GetServerContactData(); - ServerContactData = CardDAVIter->second.GetPageData(); + CardDAVIter->second->GetServerContactData(); + ServerContactData = CardDAVIter->second->GetPageData(); ClientData.LoadFile(FullFilename); // Process v3 version into v4 version. @@ -748,7 +748,7 @@ void frmActivityMgr::ProcessTasksThread() // Decided to use client version. - CardDAVIter->second.ProcessData(); + CardDAVIter->second->ProcessData(); //ETagServer = CardDAVIter->second.GetServerETagValueThread(); //ETagDBPtr->UpdateETag(ContactFilename, ETagServer, ETagServer); @@ -770,7 +770,7 @@ void frmActivityMgr::ProcessTasksThread() // Update the data to the server. - CardDAVIter->second.ProcessData(); + CardDAVIter->second->ProcessData(); } @@ -778,11 +778,12 @@ void frmActivityMgr::ProcessTasksThread() // Update the ETag DB. - CardDAVIter->second.GetServerETagValueThread(); - ETagServer = CardDAVIter->second.ETagValueResult(); + CardDAVIter->second->GetServerETagValueThread(); + ETagServer = CardDAVIter->second->ETagValueResult(); ETagDBPtr->UpdateETag(ContactFilename, ETagServer, ETagServer); iter->second = 4; + CardDAVIter->second = NULL; } else if (TypeIter->second == 2) { @@ -793,13 +794,14 @@ void frmActivityMgr::ProcessTasksThread() ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir); - CardDAVIter->second.SetUploadMode(FALSE); - CardDAVIter->second.SetupData(wxT("DELETE"), ContactFilename, wxT("")); + CardDAVIter->second->SetUploadMode(FALSE); + CardDAVIter->second->SetupData(wxT("DELETE"), ContactFilename, wxT("")); //CardDAVIter->second.SetServerFilename(); - CardDAVIter->second.ProcessData(); + CardDAVIter->second->ProcessData(); ETagDBPtr->RemoveETag(ContactFilename); iter->second = 4; + CardDAVIter->second = NULL; } else if (TypeIter->second == 3) { @@ -894,17 +896,14 @@ void frmActivityMgr::ProcessTasksThread() std::map ETagDBData = ETagDBPtr->GetETagData(); - CardDAV CardDAVInstance = CardDAVIter->second; - bool ExitLoop = FALSE; std::map *SCListData = NULL; while (ExitLoop == FALSE){ - //ServerContactList = CardDAVInstance.GetContactList(SyncTokenLoad.ToUTF8()); - ServerContactList = CardDAVIter->second.GetContactList(SyncTokenLoad.ToUTF8()); - SSLCertCollection certcol = CardDAVIter->second.GetCertificateData(); + ServerContactList = CardDAVIter->second->GetContactList(SyncTokenLoad.ToUTF8()); + SSLCertCollection certcol = CardDAVIter->second->GetCertificateData(); // Create a pointer for the std::map. @@ -912,7 +911,7 @@ void frmActivityMgr::ProcessTasksThread() // Check if any errors have occured whilst getting the data. - int ErrorCode = CardDAVIter->second.GetResultCode(); + int ErrorCode = CardDAVIter->second->GetResultCode(); if (ErrorCode != 0){ @@ -964,14 +963,14 @@ void frmActivityMgr::ProcessTasksThread() // Accept the certificate. Write the certificate into the account // directory (as server.crt) - will overwrite old certificate. - frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, CardDAVIter->second.GetCertificateData()); - WriteServerCertificate(AccountDir, CardDAVIter->second.GetCertificateData()); + frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, CardDAVIter->second->GetCertificateData()); + WriteServerCertificate(AccountDir, CardDAVIter->second->GetCertificateData()); } else if (SSLResult == 2){ // Reject the certificate, abort the task and mark as failed. - frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, CardDAVIter->second.GetCertificateData()); + frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 1, CardDAVIter->second->GetCertificateData()); iter->second = 2; break; @@ -1000,7 +999,7 @@ void frmActivityMgr::ProcessTasksThread() break; } - frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, CardDAVIter->second.GetCertificateData()); + frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, CardDAVIter->second->GetCertificateData()); // Look in directory and see which vCards to add and delete @@ -1113,9 +1112,9 @@ void frmActivityMgr::ProcessTasksThread() // Get the server contact data for comparison. - CardDAVIter->second.SetServerFilename(srviter->first); - CardDAVIter->second.GetServerContactData(); - ServerContactData = CardDAVIter->second.GetPageData(); + CardDAVIter->second->SetServerFilename(srviter->first); + CardDAVIter->second->GetServerContactData(); + ServerContactData = CardDAVIter->second->GetPageData(); FullFilename = CreateFilenamePath(AccountDirFinal, srviter->first); @@ -1249,9 +1248,9 @@ void frmActivityMgr::ProcessTasksThread() vCard34Conv vCard34Obj; - CardDAVIter->second.SetServerFilename(additer->first); - CardDAVIter->second.GetServerContactData(); - vCardInputData = CardDAVIter->second.GetPageData(); + CardDAVIter->second->SetServerFilename(additer->first); + CardDAVIter->second->GetServerContactData(); + vCardInputData = CardDAVIter->second->GetPageData(); vCard34Obj.ConvertToV4(&vCardInputData, &ConvertedV4Data); @@ -1271,8 +1270,8 @@ void frmActivityMgr::ProcessTasksThread() // Get the server ETag. wxString ServerETag; - CardDAVIter->second.GetServerETagValueThread(); - ServerETag = CardDAVIter->second.ETagValueResult(); + CardDAVIter->second->GetServerETagValueThread(); + ServerETag = CardDAVIter->second->ETagValueResult(); // Add to the ETag Database. @@ -1297,8 +1296,8 @@ void frmActivityMgr::ProcessTasksThread() // Update the ETagDB. wxString ServerETag; - CardDAVIter->second.GetServerETagValueThread(); - ServerETag = CardDAVIter->second.ETagValueResult(); + CardDAVIter->second->GetServerETagValueThread(); + ServerETag = CardDAVIter->second->ETagValueResult(); // Add to the ETag Database. @@ -1362,9 +1361,9 @@ void frmActivityMgr::ProcessTasksThread() // Compare the ETag with the Server ETag. - CardDAVIter->second.SetServerFilename(vCardAdd[vi]); - CardDAVIter->second.GetServerETagValueThread(); - ETagServer = CardDAVIter->second.ETagValueResult(); + CardDAVIter->second->SetServerFilename(vCardAdd[vi]); + CardDAVIter->second->GetServerETagValueThread(); + ETagServer = CardDAVIter->second->ETagValueResult(); if (ETagOriginal != ETagServer){ @@ -1382,8 +1381,8 @@ void frmActivityMgr::ProcessTasksThread() // Load the client data from the filename given. - CardDAVIter->second.GetServerContactData(); - ServerContactData = CardDAVIter->second.GetPageData(); + CardDAVIter->second->GetServerContactData(); + ServerContactData = CardDAVIter->second->GetPageData(); // Process v3 version into v4 version. @@ -1444,7 +1443,7 @@ void frmActivityMgr::ProcessTasksThread() // Decided to use client version. - CardDAVIter->second.ProcessData(); + CardDAVIter->second->ProcessData(); iter->second = 4; @@ -1493,15 +1492,15 @@ void frmActivityMgr::ProcessTasksThread() // Upload the data to the server. - CardDAVIter->second.SetUploadMode(TRUE); - CardDAVIter->second.SetupData(wxT("PUT"), vCardAdd[vi], TaskData); - CardDAVIter->second.ProcessData(); + CardDAVIter->second->SetUploadMode(TRUE); + CardDAVIter->second->SetupData(wxT("PUT"), vCardAdd[vi], TaskData); + CardDAVIter->second->ProcessData(); // Get the Server ETag and put it in the ETag database. - CardDAVIter->second.SetServerFilename(vCardAdd[vi]); - CardDAVIter->second.GetServerETagValueThread(); - ETagServer = CardDAVIter->second.ETagValueResult(); + CardDAVIter->second->SetServerFilename(vCardAdd[vi]); + CardDAVIter->second->GetServerETagValueThread(); + ETagServer = CardDAVIter->second->ETagValueResult(); ETagDBPtr->AddETag(vCardAdd[vi], ETagServer, ETagServer); @@ -1528,8 +1527,8 @@ void frmActivityMgr::ProcessTasksThread() // Load the client data from the filename given. - CardDAVIter->second.GetServerContactData(); - ServerContactData = CardDAVIter->second.GetPageData(); + CardDAVIter->second->GetServerContactData(); + ServerContactData = CardDAVIter->second->GetPageData(); ClientData.LoadFile(FullFilename); // Process v3 version into v4 version. @@ -1581,7 +1580,7 @@ void frmActivityMgr::ProcessTasksThread() // Decided to use client version. - CardDAVIter->second.ProcessData(); + CardDAVIter->second->ProcessData(); //ETagServer = CardDAVIter->second.GetServerETagValueThread(); //ETagDBPtr->UpdateETag(ContactFilename, ETagServer, ETagServer); @@ -1632,15 +1631,15 @@ void frmActivityMgr::ProcessTasksThread() // Upload the data to the server. - CardDAVIter->second.SetUploadMode(TRUE); - CardDAVIter->second.SetupData(wxT("PUT"), vCardAdd[vi], TaskData); - CardDAVIter->second.ProcessData(); + CardDAVIter->second->SetUploadMode(TRUE); + CardDAVIter->second->SetupData(wxT("PUT"), vCardAdd[vi], TaskData); + CardDAVIter->second->ProcessData(); // Get the Server ETag and put it in the ETag database. - CardDAVIter->second.SetServerFilename(vCardAdd[vi]); - CardDAVIter->second.GetServerETagValueThread(); - ETagServer = CardDAVIter->second.ETagValueResult(); + CardDAVIter->second->SetServerFilename(vCardAdd[vi]); + CardDAVIter->second->GetServerETagValueThread(); + ETagServer = CardDAVIter->second->ETagValueResult(); ETagDBPtr->AddETag(vCardAdd[vi], ETagServer, ETagServer); @@ -1677,9 +1676,9 @@ void frmActivityMgr::ProcessTasksThread() if (deliter->second == wxT("DELETED")){ - CardDAVIter->second.SetUploadMode(FALSE); - CardDAVIter->second.SetupData(wxT("DELETE"), deliter->first, wxT("")); - CardDAVIter->second.ProcessData(); + CardDAVIter->second->SetUploadMode(FALSE); + CardDAVIter->second->SetupData(wxT("DELETE"), deliter->first, wxT("")); + CardDAVIter->second->ProcessData(); // Delete the ETag as the file has now been deleted. @@ -1737,7 +1736,7 @@ void frmActivityMgr::ProcessTasksThread() // Update the data to the server. - CardDAVIter->second.ProcessData(); + CardDAVIter->second->ProcessData(); iter->second = 4; continue; @@ -1761,8 +1760,8 @@ void frmActivityMgr::ProcessTasksThread() AccountDir = StringAccountIter->second; ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir); - CardDAVIter->second.GetServerETagValueThread(); - ETagServer = CardDAVIter->second.ETagValueResult(); + CardDAVIter->second->GetServerETagValueThread(); + ETagServer = CardDAVIter->second->ETagValueResult(); ETagDBPtr->UpdateETag(ContactFilename, ETagServer, ETagServer); } @@ -1773,8 +1772,8 @@ void frmActivityMgr::ProcessTasksThread() AccountDir = StringAccountIter->second; ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir); - CardDAVIter->second.GetServerETagValueThread(); - ETagServer = CardDAVIter->second.ETagValueResult(); + CardDAVIter->second->GetServerETagValueThread(); + ETagServer = CardDAVIter->second->ETagValueResult(); ETagDBPtr->UpdateETag(ContactFilename, ETagServer, ETagServer); } diff --git a/source/frmActivityMgr.h b/source/frmActivityMgr.h index c29e74a..f11bf79 100644 --- a/source/frmActivityMgr.h +++ b/source/frmActivityMgr.h @@ -73,7 +73,7 @@ class frmActivityMgr : public frmActivityMgrADT std::map ActivityListAccount; std::map ActivityListFilename; std::map ActivityListFullFilename; - std::map ActivityListConn; + std::map ActivityListConn; std::map ActivityListETag; std::map ActivityListETagOriginal; std::map ActivityListFinDate;