X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=blobdiff_plain;f=source%2Fcommon%2Ftimers.cpp;h=6e49cab03045b9c3b5e91bf148de9c9c893836b5;hp=6be9a8fe75244e0045a133b1dedaf1420c03568a;hb=f69e09d827e06435ea94bb73aa71ab5f9d5c035b;hpb=12a00edc939de17f200420f5750625f384b00ef6 diff --git a/source/common/timers.cpp b/source/common/timers.cpp index 6be9a8f..6e49cab 100644 --- a/source/common/timers.cpp +++ b/source/common/timers.cpp @@ -1,322 +1,342 @@ -#include "../frmActivityMgr.h" -#include "../frmContact.h" -#include "../frmMain.h" -#include -#include -#include -#include -#include -#include "../bitmaps.h" -#include "../enums.h" -#include "../common/preferences.h" -#include "../common/etag.h" -#include "../common/dirs.h" +// timers.cpp - Timers subroutines. +// +// (c) 2012-2015 Xestia Software Development. +// +// This file is part of Xestia Address Book. +// +// Xestia Address Book is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by the +// Free Software Foundation, version 3 of the license. +// +// Xestia Address Book is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with Xestia Address Book. If not, see + +#include "timers.h" void wxActTimer::Notify(){ - - frmMain *frmMainPtrProc = static_cast(frmMainPtr); - - wxCommandEvent shuffleevent(ACTMGR_SHUFFLE); - - if (intActivityProgress == 0){ - - wxMemoryInputStream istream(misc_activity1_png, sizeof(misc_activity1_png)); - wxImage misc_activity1_pngi(istream, wxBITMAP_TYPE_PNG); - wxBitmap activityiconbmp(misc_activity1_pngi, -1); - bmpActivity->SetBitmap(activityiconbmp); - - intActivityProgress++; - - } else if (intActivityProgress == 1){ - - wxMemoryInputStream istream(misc_activity2_png, sizeof(misc_activity2_png)); - wxImage misc_activity2_pngi(istream, wxBITMAP_TYPE_PNG); - wxBitmap activityiconbmp(misc_activity2_pngi, -1); - bmpActivity->SetBitmap(activityiconbmp); - - intActivityProgress++; - - } else if (intActivityProgress == 2){ - - wxMemoryInputStream istream(misc_activity3_png, sizeof(misc_activity3_png)); - wxImage misc_activity3_pngi(istream, wxBITMAP_TYPE_PNG); - wxBitmap activityiconbmp(misc_activity3_pngi, -1); - bmpActivity->SetBitmap(activityiconbmp); - - intActivityProgress++; - - } else if (intActivityProgress == 3){ - - wxMemoryInputStream istream(misc_activity4_png, sizeof(misc_activity4_png)); - wxImage misc_activity4_pngi(istream, wxBITMAP_TYPE_PNG); - wxBitmap activityiconbmp(misc_activity4_pngi, -1); - bmpActivity->SetBitmap(activityiconbmp); - - intActivityProgress++; - - } else if (intActivityProgress == 4){ - - wxMemoryInputStream istream(misc_activity5_png, sizeof(misc_activity5_png)); - wxImage misc_activity5_pngi(istream, wxBITMAP_TYPE_PNG); - wxBitmap activityiconbmp(misc_activity5_pngi, -1); - bmpActivity->SetBitmap(activityiconbmp); - - intActivityProgress++; - - } else if (intActivityProgress == 5){ - - wxMemoryInputStream istream(misc_activity6_png, sizeof(misc_activity6_png)); - wxImage misc_activity6_pngi(istream, wxBITMAP_TYPE_PNG); - wxBitmap activityiconbmp(misc_activity6_pngi, -1); - bmpActivity->SetBitmap(activityiconbmp); - - intActivityProgress++; - - } else if (intActivityProgress == 6){ - - wxMemoryInputStream istream(misc_activity7_png, sizeof(misc_activity7_png)); - wxImage misc_activity7_pngi(istream, wxBITMAP_TYPE_PNG); - wxBitmap activityiconbmp(misc_activity7_pngi, -1); - bmpActivity->SetBitmap(activityiconbmp); - - intActivityProgress++; - - } else if (intActivityProgress == 7){ - - wxMemoryInputStream istream(misc_activity8_png, sizeof(misc_activity8_png)); - wxImage misc_activity8_pngi(istream, wxBITMAP_TYPE_PNG); - wxBitmap activityiconbmp(misc_activity8_pngi, -1); - bmpActivity->SetBitmap(activityiconbmp); - - intActivityProgress++; - - } else if (intActivityProgress == 8){ - - wxMemoryInputStream istream(misc_activity9_png, sizeof(misc_activity9_png)); - wxImage misc_activity9_pngi(istream, wxBITMAP_TYPE_PNG); - wxBitmap activityiconbmp(misc_activity9_pngi, -1); - bmpActivity->SetBitmap(activityiconbmp); - - intActivityProgress++; - - } else if (intActivityProgress == 9){ - - wxMemoryInputStream istream(misc_activity10_png, sizeof(misc_activity10_png)); - wxImage misc_activity10_pngi(istream, wxBITMAP_TYPE_PNG); - wxBitmap activityiconbmp(misc_activity10_pngi, -1); - bmpActivity->SetBitmap(activityiconbmp); - - intActivityProgress++; - - } else if (intActivityProgress == 10){ - - wxMemoryInputStream istream(misc_activity11_png, sizeof(misc_activity11_png)); - wxImage misc_activity11_pngi(istream, wxBITMAP_TYPE_PNG); - wxBitmap activityiconbmp(misc_activity11_pngi, -1); - bmpActivity->SetBitmap(activityiconbmp); - - intActivityProgress++; - - } else if (intActivityProgress == 11){ - - wxMemoryInputStream istream(misc_activity12_png, sizeof(misc_activity12_png)); - wxImage misc_activity12_pngi(istream, wxBITMAP_TYPE_PNG); - wxBitmap activityiconbmp(misc_activity12_pngi, -1); - bmpActivity->SetBitmap(activityiconbmp); - - intActivityProgress = 0; - - } - - wxPostEvent(frmMainPtrProc, shuffleevent); + + // Notify function for wxActTimer. + + frmMain *frmMainPtrProc = static_cast(frmMainPtr); + + wxCommandEvent shuffleevent(ACTMGR_SHUFFLE); + + if (intActivityProgress == 0){ + + wxMemoryInputStream istream(misc_activity1_png, sizeof(misc_activity1_png)); + wxImage misc_activity1_pngi(istream, wxBITMAP_TYPE_PNG); + wxBitmap activityiconbmp(misc_activity1_pngi, -1); + bmpActivity->SetBitmap(activityiconbmp); + + intActivityProgress++; + + } else if (intActivityProgress == 1){ + + wxMemoryInputStream istream(misc_activity2_png, sizeof(misc_activity2_png)); + wxImage misc_activity2_pngi(istream, wxBITMAP_TYPE_PNG); + wxBitmap activityiconbmp(misc_activity2_pngi, -1); + bmpActivity->SetBitmap(activityiconbmp); + + intActivityProgress++; + + } else if (intActivityProgress == 2){ + + wxMemoryInputStream istream(misc_activity3_png, sizeof(misc_activity3_png)); + wxImage misc_activity3_pngi(istream, wxBITMAP_TYPE_PNG); + wxBitmap activityiconbmp(misc_activity3_pngi, -1); + bmpActivity->SetBitmap(activityiconbmp); + + intActivityProgress++; + + } else if (intActivityProgress == 3){ + + wxMemoryInputStream istream(misc_activity4_png, sizeof(misc_activity4_png)); + wxImage misc_activity4_pngi(istream, wxBITMAP_TYPE_PNG); + wxBitmap activityiconbmp(misc_activity4_pngi, -1); + bmpActivity->SetBitmap(activityiconbmp); + + intActivityProgress++; + + } else if (intActivityProgress == 4){ + + wxMemoryInputStream istream(misc_activity5_png, sizeof(misc_activity5_png)); + wxImage misc_activity5_pngi(istream, wxBITMAP_TYPE_PNG); + wxBitmap activityiconbmp(misc_activity5_pngi, -1); + bmpActivity->SetBitmap(activityiconbmp); + + intActivityProgress++; + + } else if (intActivityProgress == 5){ + + wxMemoryInputStream istream(misc_activity6_png, sizeof(misc_activity6_png)); + wxImage misc_activity6_pngi(istream, wxBITMAP_TYPE_PNG); + wxBitmap activityiconbmp(misc_activity6_pngi, -1); + bmpActivity->SetBitmap(activityiconbmp); + + intActivityProgress++; + + } else if (intActivityProgress == 6){ + + wxMemoryInputStream istream(misc_activity7_png, sizeof(misc_activity7_png)); + wxImage misc_activity7_pngi(istream, wxBITMAP_TYPE_PNG); + wxBitmap activityiconbmp(misc_activity7_pngi, -1); + bmpActivity->SetBitmap(activityiconbmp); + + intActivityProgress++; + + } else if (intActivityProgress == 7){ + + wxMemoryInputStream istream(misc_activity8_png, sizeof(misc_activity8_png)); + wxImage misc_activity8_pngi(istream, wxBITMAP_TYPE_PNG); + wxBitmap activityiconbmp(misc_activity8_pngi, -1); + bmpActivity->SetBitmap(activityiconbmp); + + intActivityProgress++; + + } else if (intActivityProgress == 8){ + + wxMemoryInputStream istream(misc_activity9_png, sizeof(misc_activity9_png)); + wxImage misc_activity9_pngi(istream, wxBITMAP_TYPE_PNG); + wxBitmap activityiconbmp(misc_activity9_pngi, -1); + bmpActivity->SetBitmap(activityiconbmp); + + intActivityProgress++; + + } else if (intActivityProgress == 9){ + + wxMemoryInputStream istream(misc_activity10_png, sizeof(misc_activity10_png)); + wxImage misc_activity10_pngi(istream, wxBITMAP_TYPE_PNG); + wxBitmap activityiconbmp(misc_activity10_pngi, -1); + bmpActivity->SetBitmap(activityiconbmp); + + intActivityProgress++; + + } else if (intActivityProgress == 10){ + + wxMemoryInputStream istream(misc_activity11_png, sizeof(misc_activity11_png)); + wxImage misc_activity11_pngi(istream, wxBITMAP_TYPE_PNG); + wxBitmap activityiconbmp(misc_activity11_pngi, -1); + bmpActivity->SetBitmap(activityiconbmp); + + intActivityProgress++; + + } else if (intActivityProgress == 11){ + + wxMemoryInputStream istream(misc_activity12_png, sizeof(misc_activity12_png)); + wxImage misc_activity12_pngi(istream, wxBITMAP_TYPE_PNG); + wxBitmap activityiconbmp(misc_activity12_pngi, -1); + bmpActivity->SetBitmap(activityiconbmp); + + intActivityProgress = 0; + + } + + wxPostEvent(frmMainPtrProc, shuffleevent); } void wxActTimer::SetBitmap(wxStaticBitmap *bitmap) { - bmpActivity = bitmap; + // Set the bitmap for wxActTimer. + + bmpActivity = bitmap; } void wxActTimer::SetSleepBitmap(wxBitmap *SleepBitmap) { - SleepBitmapPtr = SleepBitmap; + // Set the sleep bitmap for wxActTimer. + + SleepBitmapPtr = SleepBitmap; } void wxActTimer::StopAnimation() { - // Stop the icon animation. + // Stop the icon animation. - frmMain *frmMainPtrProc = static_cast(frmMainPtr); + frmMain *frmMainPtrProc = static_cast(frmMainPtr); - wxCommandEvent actstop(ACTMGR_STOP); - wxPostEvent(frmMainPtrProc, actstop); - //frmMainPtrProc->ActivityIconStop(); + wxCommandEvent actstop(ACTMGR_STOP); + wxPostEvent(frmMainPtrProc, actstop); - this->Stop(); - bmpActivity->SetBitmap(*SleepBitmapPtr); + this->Stop(); + bmpActivity->SetBitmap(*SleepBitmapPtr); + } void wxActTimer::StartAnimation() { - frmMain *frmMainPtrProc = static_cast(frmMainPtr); - wxCommandEvent actstart(ACTMGR_START); - wxPostEvent(frmMainPtrProc, actstart); - //frmMainPtrProc->ActivityIconStart(); + frmMain *frmMainPtrProc = static_cast(frmMainPtr); + wxCommandEvent actstart(ACTMGR_START); + wxPostEvent(frmMainPtrProc, actstart); - this->ResetBitmap(); - this->Start(50, FALSE); + this->ResetBitmap(); + this->Start(50, FALSE); + } void wxActTimer::ResetBitmap() { - intActivityProgress = 0; + // Reset the bitmap for wxActTimer. + + intActivityProgress = 0; } void wxActTimer::SetupPointer(void *frmMainPtrIn) { - frmMainPtr = frmMainPtrIn; + // Setup the pointer for wxActTimer. + + frmMainPtr = frmMainPtrIn; } void wxActProcessTimer::Notify() { - // Pause the timer whilst processing to avoid problems. + // Notify function for wxActProcessTimer. + + // Pause the timer whilst processing to avoid problems. - this->Stop(); + this->Stop(); - // Process Tasks. + // Process Tasks. - frmActivityMgr *ActMgrPtrProc = static_cast(ActMgrPtr); - ActMgrPtrProc->ProcessTasks(); + frmActivityMgr *ActMgrPtrProc = static_cast(ActMgrPtr); + ActMgrPtrProc->ProcessTasks(); } void wxActProcessTimer::SetupPointers(void *ActMgr){ - ActMgrPtr = ActMgr; + // Setup pointers for the wxActProcessTimer. + + ActMgrPtr = ActMgr; } void wxActListProcTimer::Notify(){ - // Setup Label and get task data (update SetupPointers subroutine). + // Notify function for wxActListProcTimer. + + // Setup Label and get task data (update SetupPointers subroutine). - this->Stop(); + this->Stop(); - for (std::map::iterator iter = ActListPtr->begin(); - iter != ActListPtr->end(); ++iter){ + for (std::map::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::iterator LongIter = ActListUIPtr->find(iter->first); + std::map::iterator LongIter = ActListUIPtr->find(iter->first); - if (iter->second > 4){ + if (iter->second > 4){ - continue; - } + continue; + + } - std::map::iterator DetailIter = ActListDetailPtr->find(iter->first); + std::map::iterator DetailIter = ActListDetailPtr->find(iter->first); - wxCommandEvent uevent(ACTMGR_UPDATESTATUSLABEL); - ActivityMgrLabelUpdate *ueventdata = new ActivityMgrLabelUpdate; - uevent.SetClientData(ueventdata); + wxCommandEvent uevent(ACTMGR_UPDATESTATUSLABEL); + ActivityMgrLabelUpdate *ueventdata = new ActivityMgrLabelUpdate; + uevent.SetClientData(ueventdata); - if (iter->second == 1){ + if (iter->second == 1){ - ueventdata->ItemIndex = LongIter->second; - ueventdata->ItemLabel = _("Processing..."); - //ueventdata->ItemDes = _("Adding Contact '") + DetailIter->second + _("'..."); + ueventdata->ItemIndex = LongIter->second; + ueventdata->ItemLabel = _("Processing..."); - wxPostEvent(static_cast(ActMgrPtr), uevent); - - /*lstActivityPtr->SetItem(LongIter->second, 2, _("Processing...")); - if (ActListDetailPtr->find(iter->first) != ActListDetailPtr->end()){ - lblDetailsPtr->SetLabel(_("Adding Contact '") + DetailIter->second + _("'...")); - }*/ + wxPostEvent(static_cast(ActMgrPtr), uevent); - } else if (iter->second == 2){ + } else if (iter->second == 2){ - ueventdata->ItemIndex = LongIter->second; - ueventdata->ItemLabel = _("Failed"); + ueventdata->ItemIndex = LongIter->second; + ueventdata->ItemLabel = _("Failed"); - wxPostEvent(static_cast(ActMgrPtr), uevent); - iter->second = 5; + wxPostEvent(static_cast(ActMgrPtr), uevent); + iter->second = 5; - //lstActivityPtr->SetItem(LongIter->second, 2, _("Failed")); - - } else if (iter->second == 3){ + } else if (iter->second == 3){ - ueventdata->ItemIndex = LongIter->second; - ueventdata->ItemLabel = _("Stopped"); + ueventdata->ItemIndex = LongIter->second; + ueventdata->ItemLabel = _("Stopped"); - wxPostEvent(static_cast(ActMgrPtr), uevent); - iter->second = 5; - - //lstActivityPtr->SetItem(LongIter->second, 2, _("Stopped")); - //iter->second = 6; + wxPostEvent(static_cast(ActMgrPtr), uevent); + iter->second = 6; - } else if (iter->second == 4){ + } else if (iter->second == 4){ - ueventdata->ItemIndex = LongIter->second; - ueventdata->ItemLabel = _("Completed"); + ueventdata->ItemIndex = LongIter->second; + ueventdata->ItemLabel = _("Completed"); - wxPostEvent(static_cast(ActMgrPtr), uevent); - iter->second = 8; - - //lstActivityPtr->SetItem(LongIter->second, 2, _("Completed")); - //iter->second = 8; + wxPostEvent(static_cast(ActMgrPtr), uevent); + iter->second = 8; - } - - // Insert a finish date. - - wxDateTime adt; - adt = adt.Now(); - - ActListFinDTPtr->insert(std::make_pair(iter->first, adt)); + } + + // 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; + adt = adt.Now(); - } + ActListFinDTPtr->insert(std::make_pair(iter->first, adt)); + + } - if (ClearupProcessed == TRUE){ + if (ClearupProcessed == TRUE){ - // Clear up processed items. + // Clear up processed items. - // Delete the processed items. + // Delete the processed items. - ClearupProcessed = FALSE; + ClearupProcessed = FALSE; - } + } - if (*TasksActivePtr == FALSE){ + if (*TasksActivePtr == FALSE){ - ActTimerPtr->StopAnimation(); - lblDetailsPtr->SetLabel(_("No activity.")); + ActTimerPtr->StopAnimation(); + lblDetailsPtr->SetLabel(_("No activity.")); - } else { + } else { - this->Start(); + this->Start(); - } + } } @@ -324,303 +344,267 @@ 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){ - - ActListPtr = ActList; - ActListUIPtr = ActListUI; - ActListDetailPtr = ActListDetail; - TasksActivePtr = TasksActive; - lstActivityPtr = lstActivity; - lblDetailsPtr = lblDetails; - GauProgressPtr = GauProgress; - ActMgrPtr = ActMgr; - ActTimerPtr = ActTimer; - ActProcessTimerPtr = ActProcessTimer; - ActListFinDTPtr = ActListFinDT; + std::map *ActListFinDT, std::map *ActListConnObjects){ + + // Setup the pointers for wxActListProcTimer. + + ActListPtr = ActList; + ActListUIPtr = ActListUI; + ActListDetailPtr = ActListDetail; + TasksActivePtr = TasksActive; + lstActivityPtr = lstActivity; + lblDetailsPtr = lblDetails; + GauProgressPtr = GauProgress; + ActMgrPtr = ActMgr; + ActTimerPtr = ActTimer; + ActProcessTimerPtr = ActProcessTimer; + ActListFinDTPtr = ActListFinDT; + ActListConnObjectsPtr = ActListConnObjects; } void wxActListProcTimer::EnableClearup(){ - ClearupProcessed = TRUE; + // 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::iterator ETagIter; + std::map::iterator ETagIter; - for (ETagIter = ETagDBList.begin(); - ETagIter != ETagDBList.end(); ++ETagIter){ + for (ETagIter = ETagDBList.begin(); + ETagIter != ETagDBList.end(); ++ETagIter){ - if (ETagIter->second.GetWriteStatus() == TRUE){ + if (ETagIter->second.GetWriteStatus() == TRUE){ - ETagIter->second.WriteETagDB(); + ETagIter->second.WriteETagDB(); - } + } - } - + } } void wxETagProcessTimer::ReloadAccounts(){ - // Get the account preferences file and setup each database accordingly. + // Get the account preferences file and setup each database accordingly. - ReloadLock.lock(); + ReloadLock.lock(); - // Stop the timer. + // Stop the timer. - this->Stop(); - ETagDBList.clear(); + this->Stop(); + ETagDBList.clear(); - wxString PrefFilename = GetUserPrefDir(); + wxString PrefFilename = GetUserPrefDir(); - XABPreferences PrefData(PrefFilename); + XABPreferences PrefData(PrefFilename); - wxString AccountName; - wxString AccountDir; - wxString AccountAddress; - wxString AccountUsername; - wxString AccountPassword; - wxString AccountPrefix; - wxString AccountType; + wxString AccountName; + wxString AccountDir; + wxString AccountAddress; + wxString AccountUsername; + wxString AccountPassword; + wxString AccountPrefix; + wxString AccountType; - // Look for the account and get the friendly name for the account. + // Look for the account and get the friendly name for the account. - for (int i = 0; i < PrefData.accounts.GetCount(); i++){ + for (int i = 0; i < PrefData.accounts.GetCount(); i++){ - AccountDir = PrefData.accounts.GetAccountDirectory(i); - AccountType = PrefData.accounts.GetAccountType(i); + AccountDir = PrefData.accounts.GetAccountDirectory(i); + AccountType = PrefData.accounts.GetAccountType(i); + + if (AccountDir.IsEmpty()){ + continue; + } - if (AccountDir.IsEmpty()){ - continue; - } + if (AccountType != wxT("CardDAV") && AccountType != wxT("carddav")){ + continue; + } - if (AccountType == wxT("Local") || AccountType == wxT("local")){ - continue; - } + AccountDir.Trim(); + AccountDir.Append(wxT(".carddav")); - AccountDir.Trim(); - AccountDir.Append(wxT(".carddav")); + ETagDB AccountDB; + AccountDB.SetupDB(AccountDir); - ETagDB AccountDB; - AccountDB.SetupDB(AccountDir); + ETagDBList.insert(std::make_pair(AccountDir, AccountDB)); - ETagDBList.insert(std::make_pair(AccountDir, AccountDB)); + AccountDir.clear(); - AccountDir.clear(); - - } - - //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 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); + } + + ReloadLock.unlock(); + this->Start(15000); } ETagDB* wxETagProcessTimer::GetPointer(wxString AccountName){ - ETagDB *ETagDBPtr = NULL; + // Get the pointer of the ETag Database. - std::map::iterator ETagIter; + ETagDB *ETagDBPtr = NULL; - ETagIter = ETagDBList.find(AccountName); + std::map::iterator ETagIter; - if (ETagIter != ETagDBList.end()){ - - ETagDBPtr = &ETagIter->second; - - } - - return ETagDBPtr; + ETagIter = ETagDBList.find(AccountName); + + if (ETagIter != ETagDBList.end()){ + + ETagDBPtr = &ETagIter->second; + + } + + return ETagDBPtr; } void wxContactFileMonitorTimer::Notify(){ - if (Filename.IsEmpty()){ + // Notify function for wxContactFileMonitorTimer. + + if (Filename.IsEmpty()){ - return; + return; - } + } - wxFileName FileCheck(Filename); - wxDateTime CurrentDateTime; + wxFileName FileCheck(Filename); + wxDateTime CurrentDateTime; - CurrentDateTime = FileCheck.GetModificationTime(); + CurrentDateTime = FileCheck.GetModificationTime(); - if (FileDateTime != CurrentDateTime){ + if (FileDateTime != CurrentDateTime){ - // The dates & times of the file are different. - // Send an event to notify the user of this change. + // The dates & times of the file are different. + // Send an event to notify the user of this change. - wxCommandEvent dateevent(wxEVT_COMMAND_BUTTON_CLICKED); - wxPostEvent(frmCEPtr, dateevent); + wxCommandEvent dateevent(wxEVT_COMMAND_BUTTON_CLICKED); + wxPostEvent(frmCEPtr, dateevent); - } + } } void wxContactFileMonitorTimer::SetFilename(wxString FilenameInc){ - Filename = FilenameInc; + // Set the filename for the wxContactFileMonitorTimer object. - wxFileName FileCheck(Filename); - FileDateTime = FileCheck.GetModificationTime(); + Filename = FilenameInc; + + wxFileName FileCheck(Filename); + FileDateTime = FileCheck.GetModificationTime(); } void wxContactFileMonitorTimer::SetupPointers(frmContactEditor *frmCEPtrInc){ - frmCEPtr = frmCEPtrInc; + // Setup the pointers for the wxContactFileMonitorTimer object. + + frmCEPtr = frmCEPtrInc; } void wxContactFileMonitorTimer::UpdateTimestamp(){ - wxFileName FileCheck(Filename); - FileDateTime = FileCheck.GetModificationTime(); + // Update the timestamp for the wxContactFileMonitorTimer object. + + wxFileName FileCheck(Filename); + FileDateTime = FileCheck.GetModificationTime(); } 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::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 *ContactWindowListPtrInc){ - ContactWindowListPtr = ContactWindowListPtrInc; + // Setup pointers for the wxContactWindowMonitor. + + ContactWindowListPtr = ContactWindowListPtrInc; } void wxAccountSyncTimer::Notify(){ - frmActivityMgr *ActMgrPtrProc = static_cast(frmActMgrPtr); + // Notify function for the wxAccountSyncTimer. - // Disable the timer. (Don't go updating unless needed). + frmActivityMgr *ActMgrPtrProc = static_cast(frmActMgrPtr); - this->Stop(); + // Disable the timer. (Don't go updating unless needed). - if (ActMgrPtrProc->GetTaskStatus(intTaskID) < 2){ + this->Stop(); + + if (ActMgrPtrProc->GetTaskStatus(intTaskID) < 2){ - this->Start(); - return; + this->Start(); + return; - } + } - // Add task to the activity manager. + // Add task to the activity manager. - intTaskID = ActMgrPtrProc->AddTask(3, wxT(""), AccName, - wxT(""), wxT(""), wxT(""), wxT("")); + intTaskID = ActMgrPtrProc->AddTask(3, wxT(""), AccName, + wxT(""), wxT(""), wxT(""), wxT("")); - // Go to sleep and wait for the task to be completed. + // Go to sleep and wait for the task to be completed. - // Enable the timer as we are now finished syncronising. + // Enable the timer as we are now finished syncronising. - this->Start(); + this->Start(); } void wxAccountSyncTimer::SetupData(wxString AccNameInc, wxString AccNameFullInc){ - // Set the account name. + // Setup the data for the wxAccountSyncTimer object. + + // Set the account name. - AccName = AccNameInc; - AccNameFull = AccNameFullInc; + AccName = AccNameInc; + AccNameFull = AccNameFullInc; } void wxAccountSyncTimer::SetupPointers(void *frmMainPtrInc, void *frmActMgrPtrInc, ETagDB *ETagDBPtrInc){ - // Set the pointers. + // Setup the pointers for the wxAccountSyncTimer object. - frmMainPtr = frmMainPtrInc; - frmActMgrPtr = frmActMgrPtrInc; - ETagDBPtr = ETagDBPtrInc; + frmMainPtr = frmMainPtrInc; + frmActMgrPtr = frmActMgrPtrInc; + ETagDBPtr = ETagDBPtrInc; } void SleepFor(unsigned long longSleepNanoSecs){ + // Sleep for specified nano seconds. + #ifdef __WIN32__ - ::Sleep((longSleepNanoSecs / 1000000)); + ::Sleep((longSleepNanoSecs / 1000000)); #elif __HAIKU__ #else - timespec n1, n2; + timespec n1, n2; - n1.tv_sec = 0; - n1.tv_nsec = longSleepNanoSecs; + n1.tv_sec = 0; + n1.tv_nsec = longSleepNanoSecs; - nanosleep(&n1, &n2); + nanosleep(&n1, &n2); #endif