Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Move INSTALL, LICENSE, README, THANKS and TODO into root directory
[xestiaab/.git] / source / common / timers.cpp
index a0f62c7..6e49cab 100644 (file)
 // You should have received a copy of the GNU General Public License along
 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
 
-#include "../actmgr/frmActivityMgr.h"
-#include "../frmContact.h"
-#include "../frmMain.h"
-#include <wx/mstream.h>
-#include <wx/file.h>
-#include <wx/ffile.h>
-#include <wx/filename.h>
-#include <wx/tokenzr.h>
-#include "../bitmaps.h"
-#include "../enums.h"
-#include "../common/preferences.h"
-#include "../common/etag.h"
-#include "../common/dirs.h"
+#include "timers.h"
 
 void wxActTimer::Notify(){
 
+       // Notify function for wxActTimer.
+
        frmMain *frmMainPtrProc = static_cast<frmMain*>(frmMainPtr);
 
        wxCommandEvent shuffleevent(ACTMGR_SHUFFLE);
@@ -153,6 +143,8 @@ void wxActTimer::Notify(){
 void wxActTimer::SetBitmap(wxStaticBitmap *bitmap)
 {
     
+       // Set the bitmap for wxActTimer.
+    
        bmpActivity = bitmap;
     
 }
@@ -160,6 +152,8 @@ void wxActTimer::SetBitmap(wxStaticBitmap *bitmap)
 void wxActTimer::SetSleepBitmap(wxBitmap *SleepBitmap)
 {
     
+       // Set the sleep bitmap for wxActTimer.
+       
        SleepBitmapPtr = SleepBitmap;
     
 }
@@ -173,7 +167,6 @@ void wxActTimer::StopAnimation()
     
        wxCommandEvent actstop(ACTMGR_STOP);
        wxPostEvent(frmMainPtrProc, actstop);
-       //frmMainPtrProc->ActivityIconStop();
     
        this->Stop();
        bmpActivity->SetBitmap(*SleepBitmapPtr);
@@ -186,7 +179,6 @@ void wxActTimer::StartAnimation()
        frmMain *frmMainPtrProc = static_cast<frmMain*>(frmMainPtr);
        wxCommandEvent actstart(ACTMGR_START);
        wxPostEvent(frmMainPtrProc, actstart);
-       //frmMainPtrProc->ActivityIconStart();
     
        this->ResetBitmap();
        this->Start(50, FALSE);
@@ -196,6 +188,8 @@ void wxActTimer::StartAnimation()
 void wxActTimer::ResetBitmap()
 {
     
+       // Reset the bitmap for wxActTimer.
+    
        intActivityProgress = 0;
     
 }
@@ -203,6 +197,8 @@ void wxActTimer::ResetBitmap()
 void wxActTimer::SetupPointer(void *frmMainPtrIn)
 {
     
+       // Setup the pointer for wxActTimer.
+    
        frmMainPtr = frmMainPtrIn;
     
 }
@@ -210,6 +206,8 @@ void wxActTimer::SetupPointer(void *frmMainPtrIn)
 void wxActProcessTimer::Notify()
 {
     
+       // Notify function for wxActProcessTimer.
+    
        // Pause the timer whilst processing to avoid problems.
     
        this->Stop();
@@ -223,12 +221,16 @@ void wxActProcessTimer::Notify()
 
 void wxActProcessTimer::SetupPointers(void *ActMgr){
     
+       // Setup pointers for the wxActProcessTimer.
+    
        ActMgrPtr = ActMgr;
     
 }
 
 void wxActListProcTimer::Notify(){
     
+       // Notify function for wxActListProcTimer.
+    
        // Setup Label and get task data (update SetupPointers subroutine).
     
        this->Stop();
@@ -236,17 +238,17 @@ void wxActListProcTimer::Notify(){
        for (std::map<int,int>::iterator iter = ActListPtr->begin();
                iter != ActListPtr->end(); ++iter){
         
-        // Check for any queued tasks and start one.        
+               // Check for any queued tasks and start one.        
         
-        // 0 = Queued.
-        // 1 = Processing.
-        // 2 = Failed.
-        // 3 = Stopped.
-        // 4 = Completed.
-        // 5 = Failed (UI Updated).
-        // 6 = Stopped (UI Updated).
-        // 7 = (Reserved) (UI Updated).
-        // 8 = Completed. (UI Updated).
+               // 0 = Queued.
+               // 1 = Processing.
+               // 2 = Failed.
+               // 3 = Stopped.
+               // 4 = Completed.
+               // 5 = Failed (UI Updated).
+               // 6 = Stopped (UI Updated).
+               // 7 = (Reserved) (UI Updated).
+               // 8 = Completed. (UI Updated).
         
                std::map<int,long>::iterator LongIter = ActListUIPtr->find(iter->first);
        
@@ -266,14 +268,8 @@ void wxActListProcTimer::Notify(){
             
                        ueventdata->ItemIndex = LongIter->second;
                        ueventdata->ItemLabel = _("Processing...");         
-                       //ueventdata->ItemDes = _("Adding Contact '") + DetailIter->second + _("'...");
            
                        wxPostEvent(static_cast<frmActivityMgr*>(ActMgrPtr), uevent);
-           
-                       /*lstActivityPtr->SetItem(LongIter->second, 2, _("Processing..."));
-                       if (ActListDetailPtr->find(iter->first) != ActListDetailPtr->end()){
-                       lblDetailsPtr->SetLabel(_("Adding Contact '") + DetailIter->second + _("'..."));
-                       }*/
             
                } else if (iter->second == 2){
             
@@ -283,18 +279,13 @@ void wxActListProcTimer::Notify(){
                        wxPostEvent(static_cast<frmActivityMgr*>(ActMgrPtr), uevent);
                        iter->second = 5;           
 
-                       //lstActivityPtr->SetItem(LongIter->second, 2, _("Failed"));
-           
                } else if (iter->second == 3){
  
                        ueventdata->ItemIndex = LongIter->second;
                        ueventdata->ItemLabel = _("Stopped");
            
                        wxPostEvent(static_cast<frmActivityMgr*>(ActMgrPtr), uevent);
-                       iter->second = 5;
-            
-                       //lstActivityPtr->SetItem(LongIter->second, 2, _("Stopped"));
-                       //iter->second = 6;
+                       iter->second = 6;
             
                } else if (iter->second == 4){
             
@@ -303,25 +294,27 @@ void wxActListProcTimer::Notify(){
            
                        wxPostEvent(static_cast<frmActivityMgr*>(ActMgrPtr), uevent);
                        iter->second = 8;
-           
-                       //lstActivityPtr->SetItem(LongIter->second, 2, _("Completed"));
-                       //iter->second = 8;
             
                }
         
+               // 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;
                adt = adt.Now();
         
                ActListFinDTPtr->insert(std::make_pair(iter->first, adt));
-        
-               // Delete the connection object.
-       
-               std::map<int, CardDAV*>::iterator ConnObject = ActListConnPtr->find(iter->first);
-               delete ConnObject->second;
-               ConnObject->second = NULL;
-       
+
        }
     
        if (ClearupProcessed == TRUE){
@@ -351,7 +344,9 @@ 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.
     
        ActListPtr = ActList;
        ActListUIPtr = ActListUI;
@@ -364,22 +359,23 @@ void wxActListProcTimer::SetupPointers(std::map<int,int> *ActList, std::map<int,
        ActTimerPtr = ActTimer;
        ActProcessTimerPtr = ActProcessTimer;
        ActListFinDTPtr = ActListFinDT;
-       ActListConnPtr = ActListConn;
+       ActListConnObjectsPtr = ActListConnObjects;
     
 }
 
 void wxActListProcTimer::EnableClearup(){
     
+       // Enable clearup of the wxActListProcTimer.
+    
        ClearupProcessed = TRUE;
     
 }
 
 void wxETagProcessTimer::Notify(){
     
-       // Check each ETagDB and see if writing to file is required.
+       // Notify function for wxETagProcessTimer.
     
-       //ETagDB* ETagDBPtr;
-       //ETagDB ETagDBCopy;
+       // Check each ETagDB and see if writing to file is required.
     
        std::map<wxString,ETagDB>::iterator ETagIter;
     
@@ -394,7 +390,6 @@ void wxETagProcessTimer::Notify(){
         
        }
     
-    
 }
 
 void wxETagProcessTimer::ReloadAccounts(){
@@ -426,13 +421,13 @@ void wxETagProcessTimer::ReloadAccounts(){
         
                AccountDir = PrefData.accounts.GetAccountDirectory(i);
                AccountType = PrefData.accounts.GetAccountType(i);
-        
+               
                if (AccountDir.IsEmpty()){
                        continue;
                }
         
-               if (AccountType == wxT("Local") || AccountType == wxT("local")){
-               continue;
+               if (AccountType != wxT("CardDAV") && AccountType != wxT("carddav")){
+                       continue;
                }
         
                AccountDir.Trim();
@@ -447,46 +442,6 @@ void wxETagProcessTimer::ReloadAccounts(){
         
        }
     
-       //raise(SIGABRT);
-    
-       /*for (int i = 0; i < PrefData.accounts.GetCount(); i++){
-     
-       AccountDir = PrefData.accounts.GetAccountDirectory(i);
-     
-       AccountDir.Trim();
-       AccountDir.Append(wxT(".carddav"));
-
-       //AccountPrefix = PrefData.accounts.GetAccountDirPrefix(i);
-
-       //ETagDB NewETagDB (AccountDir);
-
-       ETagDB AccountDB;
-       AccountDB.SetupDB(AccountDir);
-
-       //ETagDBList.insert(std::make_pair(AccountDir, Moo));
-
-       //std::pair<wxString,ETagDB> Moo2;
-
-       //ETagDB2 Meep;
-
-       //ETagDBListv3.insert(std::make_pair(0,Meep));
-
-       //ETagDBListv2.insert(std::make_pair(0, Moo));
-
-       //ETagDBList.insert(Moo2);
-
-       ETagDBList.insert(std::make_pair(AccountDir, AccountDB));
-
-       //Moo55.insert(std::make_pair(wxT("Meep"), wxT("Meep")));
-
-       //ETagDBList[AccountDir] = new ETagDB (AccountDir);
-
-       }*/
-
-       //ETagDB Test (AccountDir);
-
-       //ETagDBList.insert(std::make_pair(AccountDir, Test));
-    
        ReloadLock.unlock();
        this->Start(15000);
     
@@ -494,6 +449,8 @@ void wxETagProcessTimer::ReloadAccounts(){
 
 ETagDB* wxETagProcessTimer::GetPointer(wxString AccountName){
     
+       // Get the pointer of the ETag Database.
+    
        ETagDB *ETagDBPtr = NULL;
     
        std::map<wxString,ETagDB>::iterator ETagIter;
@@ -512,6 +469,8 @@ ETagDB* wxETagProcessTimer::GetPointer(wxString AccountName){
 
 void wxContactFileMonitorTimer::Notify(){
     
+       // Notify function for wxContactFileMonitorTimer.
+    
        if (Filename.IsEmpty()){
         
                return;
@@ -537,6 +496,8 @@ void wxContactFileMonitorTimer::Notify(){
 
 void wxContactFileMonitorTimer::SetFilename(wxString FilenameInc){
     
+       // Set the filename for the wxContactFileMonitorTimer object.
+    
        Filename = FilenameInc;
     
        wxFileName FileCheck(Filename);
@@ -546,12 +507,16 @@ void wxContactFileMonitorTimer::SetFilename(wxString FilenameInc){
 
 void wxContactFileMonitorTimer::SetupPointers(frmContactEditor *frmCEPtrInc){
     
+       // Setup the pointers for the wxContactFileMonitorTimer object.
+    
        frmCEPtr = frmCEPtrInc;
     
 }
 
 void wxContactFileMonitorTimer::UpdateTimestamp(){
     
+       // Update the timestamp for the wxContactFileMonitorTimer object.
+    
        wxFileName FileCheck(Filename);
        FileDateTime = FileCheck.GetModificationTime();
     
@@ -559,35 +524,22 @@ void wxContactFileMonitorTimer::UpdateTimestamp(){
 
 void wxContactWindowMonitor::Notify(){
     
-       // Look through the list of windows and see if any have
-       // closed. IF they have closed then delete and free the
-       // memory (also delete from the map).
-    
-       /*for(std::map<wxString, void*>::iterator iter = ContactWindowListPtr->begin();
-       iter != ContactWindowListPtr->end(); iter++){
-     
-       frmContact *ContactPtr = (frmContact*)iter->second;
-     
-     // Check if open.
-     
-     if (
-     
-     // Delete the form.
-     
-     // Delete the data from the map.
-     
-     }*/
+       // Notify function for the wxContactWindowMonitor object.
     
 }
 
 void wxContactWindowMonitor::SetupPointers(std::map<wxString, void*> *ContactWindowListPtrInc){
     
+       // Setup pointers for the wxContactWindowMonitor.
+    
        ContactWindowListPtr = ContactWindowListPtrInc;
     
 }
 
 void wxAccountSyncTimer::Notify(){
     
+       // Notify function for the wxAccountSyncTimer.
+    
        frmActivityMgr *ActMgrPtrProc = static_cast<frmActivityMgr*>(frmActMgrPtr);
     
        // Disable the timer. (Don't go updating unless needed).
@@ -617,6 +569,8 @@ void wxAccountSyncTimer::Notify(){
 void wxAccountSyncTimer::SetupData(wxString AccNameInc,
                                    wxString AccNameFullInc){
     
+       // Setup the data for the wxAccountSyncTimer object.
+    
        // Set the account name.
     
        AccName = AccNameInc;
@@ -627,7 +581,7 @@ void wxAccountSyncTimer::SetupData(wxString AccNameInc,
 void wxAccountSyncTimer::SetupPointers(void *frmMainPtrInc, 
                                        void *frmActMgrPtrInc, ETagDB *ETagDBPtrInc){
     
-       // Set the pointers.
+       // Setup the pointers for the wxAccountSyncTimer object.
     
        frmMainPtr = frmMainPtrInc;
        frmActMgrPtr = frmActMgrPtrInc;
@@ -637,6 +591,8 @@ void wxAccountSyncTimer::SetupPointers(void *frmMainPtrInc,
 
 void SleepFor(unsigned long longSleepNanoSecs){
     
+       // Sleep for specified nano seconds.
+    
 #ifdef __WIN32__
        ::Sleep((longSleepNanoSecs / 1000000));
 #elif __HAIKU__
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