From 25c2c8c7fed1898939175dfe2871015b6099c106 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Fri, 8 Jul 2016 00:47:54 +0100 Subject: [PATCH] Implemented support to take XAB online or offline. --- source/AppXestiaAddrBk.cpp | 1 - source/AppXestiaAddrBk.h | 1 + source/actmgr/frmActivityMgr-tasks.cpp | 8 +++-- source/actmgr/frmActivityMgr.cpp | 46 +++++++++++++++++++++++--- source/actmgr/frmActivityMgr.h | 5 ++- 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/source/AppXestiaAddrBk.cpp b/source/AppXestiaAddrBk.cpp index 0f8be13..f66b81c 100644 --- a/source/AppXestiaAddrBk.cpp +++ b/source/AppXestiaAddrBk.cpp @@ -4090,7 +4090,6 @@ frmActivityMgrADT::frmActivityMgrADT( wxWindow* parent, wxWindowID id, const wxS mnuWindow->AppendSeparator(); - wxMenuItem* mnuSleepMode; mnuSleepMode = new wxMenuItem( mnuWindow, wxID_ANY, wxString( wxT("Sleep Mode") ) , wxEmptyString, wxITEM_CHECK ); mnuWindow->Append( mnuSleepMode ); diff --git a/source/AppXestiaAddrBk.h b/source/AppXestiaAddrBk.h index c7a7d2b..6bd643d 100644 --- a/source/AppXestiaAddrBk.h +++ b/source/AppXestiaAddrBk.h @@ -973,6 +973,7 @@ class frmActivityMgrADT : public wxFrame protected: wxMenuBar* mnuMenuBar; wxMenu* mnuWindow; + wxMenuItem* mnuSleepMode; wxPanel* m_panel43; wxStaticBitmap* bmpActivity; wxPanel* m_panel46; diff --git a/source/actmgr/frmActivityMgr-tasks.cpp b/source/actmgr/frmActivityMgr-tasks.cpp index 8aa7d1e..cdcdfc7 100644 --- a/source/actmgr/frmActivityMgr-tasks.cpp +++ b/source/actmgr/frmActivityMgr-tasks.cpp @@ -31,7 +31,11 @@ int frmActivityMgr::AddTask(int TaskType, wxString TaskDetail, wxString TaskAcco coldata.SetId(ActivityTaskID); coldata.SetData(ActivityTaskID); - AnimationTimer.StartAnimation(); + if (ApplicationSleepMode == FALSE){ + + AnimationTimer.StartAnimation(); + + } // Get the preferences file. @@ -193,7 +197,7 @@ int frmActivityMgr::AddTask(int TaskType, wxString TaskDetail, wxString TaskAcco ProcessTasksData = TRUE; - if (!ActProcessTimer.IsRunning()) { + if (!ActProcessTimer.IsRunning() && ApplicationSleepMode == FALSE) { wxCommandEvent event(ACTMGR_STARTTIMER); wxPostEvent(this, event); diff --git a/source/actmgr/frmActivityMgr.cpp b/source/actmgr/frmActivityMgr.cpp index 9c1e2a4..63755f8 100644 --- a/source/actmgr/frmActivityMgr.cpp +++ b/source/actmgr/frmActivityMgr.cpp @@ -45,6 +45,7 @@ DEFINE_EVENT_TYPE(ACTMGR_STOPTIMER); DEFINE_EVENT_TYPE(ACTMGR_STARTPROCESSTIMER); DEFINE_EVENT_TYPE(ACTMGR_STOPPROCESSTIMER); DEFINE_EVENT_TYPE(ACTMGR_UPDATESTATUSLABEL); +DEFINE_EVENT_TYPE(ACTMGR_STARTANIMATIONTIMER); BEGIN_EVENT_TABLE(frmActivityMgr, wxWindow) EVT_COMMAND(wxID_ANY, ACTMGR_RESUMEPROC, frmActivityMgr::ResumeProcessing) @@ -54,6 +55,7 @@ BEGIN_EVENT_TABLE(frmActivityMgr, wxWindow) EVT_COMMAND(wxID_ANY, ACTMGR_STARTPROCESSTIMER, frmActivityMgr::StartProcessTimer) EVT_COMMAND(wxID_ANY, ACTMGR_STOPPROCESSTIMER, frmActivityMgr::StopProcessTimer) EVT_COMMAND(wxID_ANY, ACTMGR_UPDATESTATUSLABEL, frmActivityMgr::UpdateStatusLabel) + EVT_COMMAND(wxID_ANY, ACTMGR_STARTANIMATIONTIMER, frmActivityMgr::StartAnimationTimer) END_EVENT_TABLE() frmActivityMgr::frmActivityMgr( wxWindow* parent ) @@ -194,6 +196,12 @@ void frmActivityMgr::ProcessTasksThread() } + if (ApplicationSleepMode == TRUE){ + + return; + + } + std::map::iterator TypeIter; std::map::iterator StringIter; std::map::iterator StringDataIter; @@ -220,6 +228,12 @@ void frmActivityMgr::ProcessTasksThread() continue; } + wxCommandEvent StartAnimationEvent(ACTMGR_STARTANIMATIONTIMER); + + wxPostEvent(this, StartAnimationEvent); + + // Start the animation timer if it hasn't started. + CardDAVIter = ActivityListConn.find(iter->first); TypeIter = ActivityListType.find(iter->first); StringETagIter = ActivityListETag.find(iter->first); @@ -2109,7 +2123,7 @@ void frmActivityMgr::ProcessTasksThread() //ActListProcTimer.Start(); } - + wxCommandEvent event(ACTMGR_STARTPROCESSTIMER); wxPostEvent(this, event); @@ -2119,7 +2133,7 @@ void frmActivityMgr::ProcessTasksThread() void frmActivityMgr::ProcessTasks() { - + std::thread ProcessThread(&frmActivityMgr::ProcessTasksThread, this); ProcessThread.detach(); @@ -2150,15 +2164,23 @@ void frmActivityMgr::ToggleConnectionStatus( wxCommandEvent &event ){ wxCommandEvent connevent(CONNSTAT_UPDATE); - if (SleepMode == FALSE){ + if (ApplicationSleepMode == FALSE){ connevent.SetInt(1); - SleepMode = TRUE; + ApplicationSleepMode = TRUE; + mnuSleepMode->Check(true); } else { connevent.SetInt(0); - SleepMode = FALSE; + ApplicationSleepMode = FALSE; + mnuSleepMode->Check(false); + + wxCommandEvent event(ACTMGR_STARTTIMER); + wxPostEvent(this, event); + + wxCommandEvent eventp(ACTMGR_STARTPROCESSTIMER); + wxPostEvent(this, eventp); } @@ -2166,6 +2188,14 @@ void frmActivityMgr::ToggleConnectionStatus( wxCommandEvent &event ){ } +void frmActivityMgr::SleepMode( wxCommandEvent &event ){ + + wxCommandEvent connevent(ACTMGR_TOGGLECONN); + + wxPostEvent(this, connevent); + +} + void frmActivityMgr::WriteServerCertificate(wxString AccountName, SSLCertCollection SSLCertInc){ wxString ServerCertFinal; @@ -2210,6 +2240,12 @@ void frmActivityMgr::StopProcessTimer(wxCommandEvent& event){ } +void frmActivityMgr::StartAnimationTimer(wxCommandEvent& event){ + + AnimationTimer.StartAnimation(); + +} + void frmActivityMgr::UpdateStatusLabel(wxCommandEvent& event){ ActivityMgrLabelUpdate *actmgrudata = (ActivityMgrLabelUpdate*)event.GetClientData(); diff --git a/source/actmgr/frmActivityMgr.h b/source/actmgr/frmActivityMgr.h index fec4778..d6dc31a 100644 --- a/source/actmgr/frmActivityMgr.h +++ b/source/actmgr/frmActivityMgr.h @@ -53,6 +53,7 @@ DECLARE_EVENT_TYPE(ACTMGR_STOPTIMER, wxID_ANY) DECLARE_EVENT_TYPE(ACTMGR_STARTPROCESSTIMER, wxID_ANY) DECLARE_EVENT_TYPE(ACTMGR_STOPPROCESSTIMER, wxID_ANY) DECLARE_EVENT_TYPE(ACTMGR_UPDATESTATUSLABEL, wxID_ANY) +DECLARE_EVENT_TYPE(ACTMGR_STARTANIMATIONTIMER, wxID_ANY) struct vCardDownloadDataFileClass{ unsigned int DataType = 0; @@ -114,7 +115,7 @@ class frmActivityMgr : public frmActivityMgrADT std::map ActivityListLog; bool WindowOpen = FALSE; bool TasksActive = FALSE; - bool SleepMode = FALSE; + bool ApplicationSleepMode = FALSE; bool ProcessTasksData = FALSE; //int ConflictResult = 0; wxETagProcessTimer *ETagTmrPtr; @@ -134,10 +135,12 @@ class frmActivityMgr : public frmActivityMgrADT void StopTimer( wxCommandEvent& event ); void StartProcessTimer( wxCommandEvent& event ); void StopProcessTimer( wxCommandEvent& event ); + void StartAnimationTimer(wxCommandEvent& event); void FlushAllTasks(); void RemoveTask(); void ProcessTasksThread(); void ToggleConnectionStatus( wxCommandEvent& event ); + void SleepMode( wxCommandEvent &event ); void WriteServerCertificate(wxString AccountName, SSLCertCollection SSLCertInc); void UpdateStatusLabel( wxCommandEvent& event ); public: -- 2.39.5