Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Removed references of CardDAV and delete ConnectionObject when finished
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 10 Sep 2016 17:39:07 +0000 (18:39 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 10 Sep 2016 17:39:07 +0000 (18:39 +0100)
source/actmgr/frmActivityMgr-tasks.cpp
source/actmgr/frmActivityMgr.cpp
source/actmgr/frmActivityMgr.h
source/common/timers.cpp
source/common/timers.h

index 2efca05..842598d 100644 (file)
@@ -293,10 +293,6 @@ void frmActivityMgr::RetryTask( wxCommandEvent& event ){
                return;
        }
        
-       std::map<int,CardDAV*>::iterator CDAVter;
-       
-       CDAVter = ActivityListConn.find(intSelectedData);
-       
        // Restart the task.
        
        //CDAVter->second.Abort();
index 40ab583..ec4700c 100644 (file)
@@ -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<wxString,wxString> vCardETag;
-                                       ContactListData ServerContactList;
                                
                                        std::map<wxString,vCardDownloadDataFileClass> vCardDownloadData;
                                
@@ -1017,8 +1016,6 @@ void frmActivityMgr::ProcessTasksThread()
                                        COConnectResult ConnectResponse = ConnObjectIter->second->Connect(false);
                                        
                                        bool ExitLoop = FALSE;
-
-                                       std::map<wxString,FileSyncData> *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++){
index 2c6ffc6..9947ea4 100644 (file)
@@ -108,7 +108,6 @@ class frmActivityMgr : public frmActivityMgrADT
                std::map<int,wxString> ActivityListAccount;
                std::map<int,wxString> ActivityListFilename;
                std::map<int,wxString> ActivityListFullFilename;
-               std::map<int,CardDAV*> ActivityListConn;
                std::map<int,ConnectionObject*> ActivityListConnObject;
                std::map<int,ActivityMgrAccountSettings> ActivityListAccSettings;
                std::map<int,wxString> ActivityListETag;
index 88bbb3e..4ba3e94 100644 (file)
@@ -297,7 +297,7 @@ void wxActListProcTimer::Notify(){
                        ueventdata->ItemLabel = _("Stopped");
            
                        wxPostEvent(static_cast<frmActivityMgr*>(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<int,ConnectionObject*>::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<int,int> *ActList, std::map<int,
                                        std::map<int,wxString> *ActListDetail, bool *TasksActive,
                                        wxListCtrl *lstActivity, wxStaticText *lblDetails, wxGauge *GauProgress,
                                        void *ActMgr, wxActTimer *ActTimer, wxActProcessTimer *ActProcessTimer,
-                                       std::map<int,wxDateTime> *ActListFinDT, std::map<int, CardDAV*> *ActListConn){
+                                       std::map<int,wxDateTime> *ActListFinDT, std::map<int,ConnectionObject*> *ActListConnObjects){
     
        // Setup the pointers for wxActListProcTimer.
     
@@ -360,7 +371,7 @@ void wxActListProcTimer::SetupPointers(std::map<int,int> *ActList, std::map<int,
        ActTimerPtr = ActTimer;
        ActProcessTimerPtr = ActProcessTimer;
        ActListFinDTPtr = ActListFinDT;
-       ActListConnPtr = ActListConn;
+       ActListConnObjectsPtr = ActListConnObjects;
     
 }
 
index 4bb4482..0af0942 100644 (file)
@@ -23,6 +23,7 @@
 #include <atomic>
 #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<int,int> *ActListPtr;
-    std::map<int,long> *ActListUIPtr;
-    std::map<int,wxString> *ActListDetailPtr;
-    std::map<int,CardDAV*> *ActListConnPtr;
-    wxListCtrl *lstActivityPtr;
-    wxStaticText *lblDetailsPtr;
-    bool *TasksActivePtr;
-    wxGauge *GauProgressPtr;
-    void *ActMgrPtr;
+    std::map<int,int> *ActListPtr = nullptr;
+    std::map<int,long> *ActListUIPtr = nullptr;
+    std::map<int,wxString> *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<int,wxDateTime> *ActListFinDTPtr;
+    wxActTimer *ActTimerPtr = nullptr;
+    wxActProcessTimer *ActProcessTimerPtr = nullptr;
+    std::map<int,wxDateTime> *ActListFinDTPtr = nullptr;
+    std::map<int,ConnectionObject*> *ActListConnObjectsPtr = nullptr;
     bool ClearupProcessed = FALSE;
 public:
     wxActListProcTimer():wxTimer()
@@ -97,7 +97,7 @@ public:
                        std::map<int,wxString> *ActListDetail, bool *TasksActive,
                        wxListCtrl *lstActivity, wxStaticText *lblDetails, wxGauge *GauProgress,
                        void *ActMgr, wxActTimer *ActTimer, wxActProcessTimer *ActProcessTimer,
-                       std::map<int,wxDateTime> *ActListFinDT, std::map<int, CardDAV*> *ActListConn);
+                       std::map<int,wxDateTime> *ActListFinDT, std::map<int,ConnectionObject*> *ActListConnObjects);
     void EnableClearup();
     
 };
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