| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730 |
- #pragma once
- #include "stdafx.h"
- #include "SpFSM.h"
- #define JUS_A_TEST 0
- #include "FileInfo.h"
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- #include <stdarg.h>
- #include <string>
- #include <vector>
- #include <assert.h>
- #include <time.h>
- #include <map>
- #if defined(RVC_OS_WIN)
- #include <ws2tcpip.h>
- #include <tchar.h>
- #include <atlbase.h>
- #include <conio.h>
- #include "mbnapi.h"
- #include <comdef.h>
- #else
- #include <sys/sysinfo.h>
- #include <time.h>
- #include <sys/types.h>
- #include <dirent.h>
- #include <sys/stat.h>
- #endif //RVC_OS_WIN
- using namespace std;
- #include "CardSwiper_client_g.h"
- #include "CardSwiper_msg_g.h"
- #include "CardSwiper_def_g.h"
- #include "EventCode.h"
- #include "FileSimpleComp.h"
- #include "CommEntityUtil.hpp"
- #define DEFAULT_INTERVAL 1000
- #define SYSVAR_DISKSTATEUS_FOR_VIDEO "VideoSpaceStatus" //录像磁盘空间状态系统变量
- #define VIDEO_SPACE_UNKNOWN "U" // 未知:未初始化或其他原因
- #define VIDEO_SPACE_SUFFICIENT "S" // 空间充足,3,0
- #define VIDEO_SPACE_INSUFF_LITTLE "W" // 低级警告:磁盘空间不足以支持七天以上录像,2
- #define VIDEO_SPACE_INSUFF_LESS "E" // 高级警告:磁盘空间不足以支持三天以上录像,1
- #define VIDEO_SPACE_INSUFF_FATAL "F" // 严重错误:磁盘空间不足以支持一天以上录像, 4
- #define OPT_FILE_CMD_SPREAD 0
- #define OPT_FILE_CMD_EXECUTE 1
- #define OPT_FILE_CMD_DELETE 2
- #define OPT_FILE_CMD_CLEAR 3
- #define OPT_FILE_CMD_CREATE 4
- #define OPT_FILE_CMD_APPEND 5
- #define OPT_FILE_CMD_RENAME 6
- #define OPT_FILE_RES_SUCCESS 1
- #define OPT_FILE_RES_INVALID -1
- #define OPT_FILE_RES_FAILED -2
- #define OPT_FILE_RES_NOT_SUPPORT -3
- #define SYSVAR_FRAMEWORK_FIRST_BOOT "FirstLaunchSinceSysBoot" //框架开机后首次启动标识
- #define SYSVAR_FRAMEWORK_FIRST_BOOT_YES "Y"
- #define SYSVAR_FRAMEWORK_FIRST_BOOT_NO "N"
- //Black sheet access attribute
- #define BS_DENY_READ 0x00000001
- #define BS_DENY_MODIFY 0x00000002 //Actually Append action.
- #define BS_DENY_EXECUTE 0x00000004
- #define BS_DENY_DELETE 0x00000008
- #define BS_DENY_CREATE 0x00000010
- #define BS_DENY_INHERITED 0x10000000
- #define BS_ACCESS_ALL ((DWORD)-1)
- #define LIMITED_SYS_COUNT 3
- static const char* limited_sys_paths[LIMITED_SYS_COUNT] =
- {
- "Program Files",
- "ProgramData",
- "Program Files (x86)"
- };
- #define LIMITED_SYS_PATH(x) \
- limited_sys_paths[x]
- class CustomSignalEvents;
- enum EvtType
- {
- USER_EVT_FETCH = EVT_USER + 1,
- USER_EVT_RUN,
- USER_EVT_GET_CARDSWIPER_STATUS,
- USER_EVT_GET_CARDSWIPER_STATUS_FINISHED,
- USER_EVT_CLEAR_UPLOADEDVIDEOFILES,
- USER_EVT_CLEAR_UPLOADEDVIDEOFILES_FINISHED,
- USER_EVT_CLEAR_VIDEOFILE_ENHANCE,
- USER_EVT_CLEAR_VIDEOFILE_ENHANCE_FINISHED,
- USER_EVT_VERSION_CLEAR,
- USER_EVT_VERSION_CLEAR_FINISHED,
- USER_EVT_FILE_OPERAT,
- USER_EVT_FILE_OPERAT_FINISHED,
- USER_EVT_GET_EVENTLOG,
- USER_EVT_GET_EVENTLOG_FINISHED
- };
- enum DealFileType
- {
- DFT_CenterSetting,
- DFT_Ad0
- };
- #include "ResourceWatcher_server_g.h"
- #include "ResourceWatcher_msg_g.h"
- using namespace ResourceWatcher;
- using namespace CardSwiper;
- #if defined(_MSC_VER)
- #define WIDE_CONDITION
- #ifdef WIDE_CONDITION
- #include "EventLogW.h"
- typedef CEventLogW CEventLog;
- typedef EVENTLOGPARAM_W EVENTLOGPARAM;
- typedef LPEVENTLOGPARAM_W LPEVENTLOGPARAM;
- #else
- #include "EventLog.h"
- #endif //WIDE_CONDITION
- #endif //RVC_OS_WIN
- class CardSwiperClient;
- struct CInstallInfoEx : public CInstallInfo
- {
- CInstallInfoEx(const CInstallInfo& info)
- :CInstallInfo(info)
- {/* empty */
- }
- bool operator < (const CInstallInfoEx& rhs) const
- {
- CVersion l_version(this->InstallVersion);
- DWORD l_timeTick = (DWORD)this->tmSwithOverDate;
- CVersion r_version(rhs.InstallVersion);
- DWORD r_timeTick = (DWORD)rhs.tmSwithOverDate;
- if (l_version == r_version)
- return l_timeTick <= r_timeTick;
- return l_version > r_version;
- }
- };
- class FetchEvent : public FSMEvent
- {
- public:
- FetchEvent() : FSMEvent(USER_EVT_FETCH) {}
- virtual ~FetchEvent() {}
- SpReqAnsContext<ResourceWatcherService_Fetch_Req, ResourceWatcherService_Fetch_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL) {
- ctx->Answer(Error_InvalidState);
- }
- }
- };
- //chenjilin hardware change
- typedef struct CPUInfoStruct
- { // 记录 /proc/stat 中的CPU信息
- char name[20];
- unsigned int user;
- unsigned int nice;
- unsigned int system;
- unsigned int idle;
- unsigned int lowait;
- unsigned int irq;
- unsigned int softirq;
- }CPUInfo;
- typedef struct MemInfoStruct // 记录 /proc/meminfo 中的内存信息
- {
- char infoName1[20];
- unsigned long memTotal;
- char infoName2[20];
- unsigned long memFree;
- char infoName3[20];
- unsigned long memAvail;
- }MemInfo;
- //change end
- class ResourceWatcherFSM : public FSMImpl<ResourceWatcherFSM>
- {
- public:
- ResourceWatcherFSM(void);
- ~ResourceWatcherFSM(void);
- enum { s0, s1, s2, s3 };
- BEGIN_FSM_STATE(ResourceWatcherFSM)
- FSM_STATE_ENTRY(s0, "Idle", s0_on_entry, s0_on_exit, s0_on_event)
- FSM_STATE_ENTRY(s1, "Running", s1_on_entry, s1_on_exit, s1_on_event)
- FSM_STATE_ENTRY(s2, "Failed", s2_on_entry, s2_on_exit, s2_on_event)
- FSM_STATE_ENTRY(s3, "Listerning", s3_on_entry, s3_on_exit, s3_on_event)
- END_FSM_STATE()
- BEGIN_FSM_RULE(ResourceWatcherFSM, s0)
- FSM_RULE_ENTRY(s0, s1, USER_EVT_RUN, 0)
- FSM_RULE_ENTRY(s1, s3, USER_EVT_CLEAR_VIDEOFILE_ENHANCE_FINISHED, 0)
- END_FSM_RULE()
- virtual ErrorCodeEnum OnInit();
- virtual ErrorCodeEnum OnExit();
- void AfterInit();
- virtual void s0_on_entry();
- virtual void s0_on_exit();
- virtual unsigned int s0_on_event(FSMEvent* e);
- virtual void s1_on_entry();
- virtual void s1_on_exit();
- virtual unsigned int s1_on_event(FSMEvent* e);
- virtual void s2_on_entry();
- virtual void s2_on_exit();
- virtual unsigned int s2_on_event(FSMEvent* e);
- virtual void s3_on_entry();
- virtual void s3_on_exit();
- virtual unsigned int s3_on_event(FSMEvent* e);
- void SelfTest(EntityTestEnum eTestType, CSmartPointer<ITransactionContext> pTransactionContext);
- int GetCardSwiperVal() const
- {
- return m_cardswiperStatus;
- }
- BOOL IsFirstRunAfterBoot() const
- {
- return m_bFirstRunAfterBoot;
- }
- BOOL IsInitMode() const
- {
- Dbg("%s: %u", __FUNCTION__, m_bIsConfigMode);
- return m_bIsConfigMode;
- }
- void UploadMonitorSettings();
- private:
- void readVideoStoreData();
- private:
- BOOL m_IsPadDevice;
- //Cardswiper Component
- BOOL m_bGetStatusRotate;
- //Video Component
- CSimpleStringA m_uploadedVideoDirPath;
- CSimpleStringA m_csDelFileSuffix;
- int m_nDayOfBackward;
- int m_failDelCnt;
- bool m_bReadyFlag;
- //Video Component2
- priority_queue<TmpFileInfo*, vector<TmpFileInfo*>, Comparetor> m_VideoFiles;
- //日期,数量
- map<UINT, UINT> VideoDailyRecord;
- char szMaxSizeFilePath[MAX_PATH];
- #if defined(_MSC_VER)
- FILETIME m_ftRemoveTime;
- ULARGE_INTEGER mAllVideoFileSizeCal;
- ULARGE_INTEGER mMaxFileSize;
- ULARGE_INTEGER mUiCalibration;
- ULARGE_INTEGER mUiRequireBytes;
- FILETIME mftAd0RemoveTime;
- #else
- unsigned long long mAllVideoFileSizeCal;
- unsigned long long mMaxFileSize;
- unsigned long long mUiCalibration;
- unsigned long long mUiRequireBytes;
- time_t mftAd0RemoveTime;
- #endif //_MSC_VER
- typedef map<UINT, UINT>::const_iterator const_map_cu_iter;
- DiskInfo diskInfo;
- bool m_bVideoClearReady;
- int m_nMinSavedDay;
- //CPU Component
- int m_highPart;
- int m_lowPart;
- typedef std::string bs_key;
- typedef DWORD bs_value;
- typedef map<bs_key, bs_value> BLACK_LIST;
- typedef BLACK_LIST::const_iterator const_bs_iter;
- typedef BLACK_LIST::iterator bs_iter;
- typedef std::pair<bs_key, bs_value> BlackSheetPair;
- std::map<std::string, DWORD> m_forbidDirList;
- CSimpleStringA m_strTerminalNo;
- CSimpleStringA m_strDefaultDns;
- CSimpleStringA m_strBackupDns;
- int m_nEnableSetDns;
- FILE_LAYOUT_ENTRY m_FileEntry;
- BOOL m_bFirstRunAfterBoot;
- BOOL m_bIsConfigMode;
- public:
- int GetCardSwiperStatus();
- int m_cardswiperStatus;
- //Start Video Component [Josephus in 9:12:26 2016/4/14]
- int CleanVideoFiles(int& newDeletedFilesNum, int initFlag = 1);
- #if defined(_MSC_VER)
- void CalculateBackTime(PFILETIME ftResultTime, int days);
- BOOL CalculateWillUploadDirSize(ULARGE_INTEGER& uiBytesCal);
- /*
- *-1, First file time is earlier than second file time.
- * 0, First file time is equal to second file time
- * 1, First file time is later than second file time.
- */
- LONG CompareVideoFileTime(PFILETIME ftCurTime, PFILETIME fileTime)
- {
- return CompareFileTime(ftCurTime, fileTime);
- }
- void SyncUpdateVideoCreateDaily(const FILETIME* ft, int minusOrAdd)
- {
- SYSTEMTIME stUTC, stLocal;
- FileTimeToSystemTime(ft, &stUTC);
- SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
- UINT uDate = stLocal.wYear * 10000 + stLocal.wMonth * 100 + stLocal.wDay;
- VideoDailyRecord[uDate] += minusOrAdd;
- }
- // Start CPU Componet --Josephus at 9:05:24 2016121
- void InitialCPUMarkInfor();
- int SelectMarkLevel(int nValue)
- {
- if (m_highPart == m_lowPart && m_highPart == 0)
- return 0;
- if (m_lowPart == 0) {//no low config
- if (nValue >= m_highPart)
- return 1;
- else
- return 2;
- } else if (m_highPart == 0) {
- if (nValue > m_lowPart)
- return 2;
- else
- return 3;
- } else if (m_lowPart >= m_highPart) {//low standard.
- if (nValue > m_lowPart)
- return 2;
- else
- return 3;
- }
- if (nValue <= m_lowPart)
- return 3;
- if (nValue < m_highPart)
- return 2;
- return 1;
- }
- BOOL GetCPUBrand(CSimpleStringA& csCpuBrand);
- void RecordVideoFileInfomation(LPCTSTR lpFilePath, PWIN32_FIND_DATA pWfdata);
- int CalculateAllVideoSize(LPCTSTR lpszPath, PULARGE_INTEGER puliSpaceBytes);
- // Add -Josephus@2017713 16:04:18
- DWORD CalSpecifiedSecondsFrom1970(const WORD wDuration,
- DWORD* dwStartTime
- , DWORD* dwEndTime
- , const PULONGLONG pStartTime
- , const PULONGLONG pEndTime);
- DWORD CombineTheEvtxFileName(LPCTSTR lpszTerminalNo, CHAR szEvtxFileName[]);
- DWORD GetEventLog(SpReqAnsContext<ResourceWatcherService_ExtractEventLog_Req,
- ResourceWatcherService_ExtractEventLog_Ans>::Pointer ctx);
- BOOL RetrieveSpecificedEventLogs(const LPEVENTLOGPARAM pEvtLogFilter,
- LPCTSTR lpszEvtFileName, DWORD& dwEntries);
- HRESULT SetDefaultAudioPlaybackDevice(LPCWSTR devID);
- BOOL SetDefaultAudioDevice();
- #else
- LONG CompareVideoFileTime(const time_t* ftCurTime, const time_t* fileTime)
- {
- if (*ftCurTime == *fileTime) return 0;
- if (*ftCurTime < *fileTime) return -1;
- return 1;
- }
- void CalculateBackTime(time_t* ftResultTime, int days);
- BOOL CalculateWillUploadDirSize(unsigned long long& uiBytesCal);
- void SyncUpdateVideoCreateDaily(const time_t* ft, int minusOrAdd)
- {
- tm* backtime = localtime(ft);
- const UINT uDate = (1900 + backtime->tm_year) * 10000 + (1 + backtime->tm_mon) * 100 + backtime->tm_mday;
- VideoDailyRecord[uDate] += minusOrAdd;
- }
- void RecordVideoFileInfomation(LPCTSTR lpFilePath, struct stat* pWfdata);
- int CalculateAllVideoSize(LPCTSTR lpszPath, unsigned long long* puliSpaceBytes);
- #endif //_MSC_VER
- void AppendVideoSizeTogether();
- void CalculateFreeDiskNeeded();
- void RecordFreeDiskNeededToRunCfg();
- void GetFreeDiskNeededFromRunCfg();
- int RemoveExpireVideoFileAndRecord(LPCTSTR dirName, int& deletedFileCnt, int& deleteFailedCnt, const int nFlag);
- // End Video Component
- ErrorCodeEnum GetCpuType(
- SpReqAnsContext<ResourceWatcherService_GetCpuType_Req,
- ResourceWatcherService_GetCpuType_Ans>::Pointer ctx);
- // Start CenterSetting Clear Job --Josephus at 15:57:58 20161210
- BOOL RemoveDuplicateCenterSettingFiles();
- int ClearSpecifieFile(DealFileType fileType, LPCTSTR dirName, int& deletedFileCnt, int& deleteFailedCnt);
- int RemoveSpecifiedFile(DealFileType fileType, LPCTSTR szFilePath, LPCTSTR szFileName);
- // End CenterSetting clear Job
- // Start Video Component2 --Josephus at 16:19:56 201755
- void ClearVideoQueue();
- // Has been purified --Josephus at 10:42:55 201759
- void PrintVideEmurateResult();
- void CleanMoreVideoFiles();
- bool IsNeedToFirstClear();
- void SetSysValAndBroadcast(DWORD dwVal, LPCTSTR lpszMessage);
- // End --Josephus at 16:20:02 201755
- BOOL DeleteVersionPackage();
- BOOL DeleteSpecificeVersionDir(CVersion version);
- int ProcessFileDelete(LPCTSTR lpszPath, int& nDelSucCnt, int& nDelFailedCnt);
- DWORD InitialVolumes();
- BOOL InitialDirectoryEntity(LPCTSTR lpszPath, DWORD& dwFileCnt, const DWORD dwFilterAttributes = 0UL);
- DWORD ProcessFileOperation(const SpReqAnsContext<ResourceWatcherService_OperateFile_Req,
- ResourceWatcherService_OperateFile_Ans>::Pointer& ctx);
- DWORD ExecuteFile(LPCTSTR lpszFilePath, LPCTSTR lpParam);
- BOOL ConveyFileEntityToContext(const SpReqAnsContext<ResourceWatcherService_OperateFile_Req,
- ResourceWatcherService_OperateFile_Ans>::Pointer& ctx, BOOL bRefleshHeader = FALSE
- , DWORD dwFilterAttributes = 0);
- /*
- option: 0::scan, 2::delete
- */
- int FilterFilePathAhead(LPCTSTR lpszPath, const int option);
- void InitBlackList();
- BOOL InBlackListOrNot(LPCTSTR lpszPath, const int option);
- // Add Ad0 folder job [4/2/2018 10:53 @Gifur]
- BOOL ClearAd0Folder();
- BOOL IsTodayDone(int nRecordTime);
- BOOL GetSystemBootTime(CSmallDateTime& systemBootTime);
- BOOL DetectIsFirstRunAtBoot();
- /** 返回操作系统当前的版本,比如1032,1010,1031*/
- UINT GetSystemDisplayVersion(CSimpleStringA& strVersion);
- void UploadSysVersionInfo(UINT& ver);
- string CPUProcessStatus();
- string MemoryProcessStatus();
- void HardwareInfoTimer(void* pData);
-
- void LinkDetect(int detectType, const char* url, bool& status, uint &delay);
- //void MainLinkDetectTimer(void* pData);
- void GetMainLinkStatus();
- ErrorCodeEnum BizLinkDetect(
- SpReqAnsContext<ResourceWatcherService_BizLinkDetect_Req,
- ResourceWatcherService_BizLinkDetect_Ans>::Pointer ctx);
- ErrorCodeEnum CheckNetType(
- SpReqAnsContext<ResourceWatcherService_CheckNetType_Req,
- ResourceWatcherService_CheckNetType_Ans>::Pointer ctx);
- ErrorCodeEnum GetBizLinks(
- SpReqAnsContext<ResourceWatcherService_GetBizLinks_Req,
- ResourceWatcherService_GetBizLinks_Ans>::Pointer ctx);
-
- BOOL ReadCPUInfo(CPUInfo* cpu);
- void GetSystemCPUStatus();
- void GetSystemMemoryStatus();
- void GetSystemDiskStatus();
- void GetOperationDiskStatus();
- void GetDiskStatusFrom(LPCTSTR path);
- void ConfirmWindowEffectHasBeenOpen();
- void switchWindowsEffect(const char* cfgFilePath, bool enable);
- BOOL SetLocalDNSWithResolv(LPCTSTR dns1, LPCTSTR dns2);
- BOOL SetLocalDNSWithNetworkManager(LPCTSTR dns1, LPCTSTR dns2);
- BOOL SetLocalDNSWithInterfaces(LPCTSTR dns1, LPCTSTR dns2);
- void ConfirmDNSConfigHasSet();
- BOOL readDNSConfigFile(CSimpleStringA& result);
- /** 1032操作系统版本出现剪贴板和操作中心,需要将剪贴板关掉避免手势唤起
- * 统信的人告知可以通过删除剪贴板程序实现……JUST DO IT!
- */
- void ConfirmDDEClipboardDisable();
- void RecoverDDEClipboardEnable();
- /** 自己摸索,统信说需要操作系统定制方能解决 [Gifur@202198]*/
- void ConfirmNotificationCenterDisable();
- };
- class RunEvent : public FSMEvent
- {
- public:
- RunEvent() : FSMEvent(USER_EVT_RUN) {}
- virtual ~RunEvent() {}
- };
- class OperateFileEvent : public FSMEvent
- {
- public:
- OperateFileEvent()
- : FSMEvent(USER_EVT_FILE_OPERAT)
- , m_ctx(NULL)
- {
- }
- ~OperateFileEvent() {}
- SpReqAnsContext<ResourceWatcherService_OperateFile_Req,
- ResourceWatcherService_OperateFile_Ans>::Pointer m_ctx;
- virtual void OnUnhandled()
- {
- if (m_ctx != NULL) {
- Dbg("Operate file event unhandled");
- m_ctx->Ans.result = OPT_FILE_RES_FAILED;
- m_ctx->Answer(Error_Succeed);
- }
- }
- };
- class GetEventLogEvent : public FSMEvent
- {
- public:
- GetEventLogEvent(SpReqAnsContext<ResourceWatcherService_ExtractEventLog_Req,
- ResourceWatcherService_ExtractEventLog_Ans>::Pointer ctx)
- : FSMEvent(USER_EVT_GET_EVENTLOG)
- , m_ctx(ctx)
- {
- }
- ~GetEventLogEvent() {}
- SpReqAnsContext<ResourceWatcherService_ExtractEventLog_Req,
- ResourceWatcherService_ExtractEventLog_Ans>::Pointer m_ctx;
- virtual void OnUnhandled()
- {
- if (m_ctx != NULL) {
- Dbg("get event log event unhandled");
- }
- }
- };
- struct GetCardSwiperTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- GetCardSwiperTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
- void Process()
- {
- FSMEvent* fsmEvent = new FSMEvent(USER_EVT_GET_CARDSWIPER_STATUS_FINISHED);
- fsmEvent->param1 = m_pFSM->GetCardSwiperStatus();
- m_pFSM->PostEventFIFO(fsmEvent);
- }
- };
- struct ClearVideoFilesTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- ClearVideoFilesTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM), m_nInitFlag(1) {}
- int m_nInitFlag;
- void SetFlag(int nFlag) { m_nInitFlag = nFlag; }
- void Process()
- {
- FSMEvent* fsmEvent = new FSMEvent(USER_EVT_CLEAR_UPLOADEDVIDEOFILES_FINISHED);
- int value(0);
- fsmEvent->param2 = m_pFSM->CleanVideoFiles(value, m_nInitFlag);
- fsmEvent->param1 = value;
- m_pFSM->PostEventFIFO(fsmEvent);
- }
- };
- struct ClearVideoFilesEnhanceTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- ClearVideoFilesEnhanceTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
- void Process()
- {
- FSMEvent* fsmEvent = new FSMEvent(USER_EVT_CLEAR_VIDEOFILE_ENHANCE_FINISHED);
- m_pFSM->CleanMoreVideoFiles();
- m_pFSM->PostEventFIFO(fsmEvent);
- }
- };
- struct ClearCenterSettingFilesTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- ClearCenterSettingFilesTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
- void Process()
- {
- m_pFSM->RemoveDuplicateCenterSettingFiles();
- }
- };
- struct ClearVersionTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- ClearVersionTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
- void Process()
- {
- m_pFSM->DeleteVersionPackage();
- }
- };
- struct UploadMonitorInfoTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- UploadMonitorInfoTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
- void Process()
- {
- m_pFSM->UploadMonitorSettings();
- }
- };
- struct ClearAd0Task : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- ClearAd0Task(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM), m_nInitFlag(1) {}
- int m_nInitFlag;
- void SetFlag(int nFlag) { m_nInitFlag = nFlag; }
- void Process()
- {
- m_pFSM->ClearAd0Folder();
- }
- };
- struct RunTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- RunTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM), m_nInitFlag(1) {}
- int m_nInitFlag;
- void SetFlag(int nFlag) { m_nInitFlag = nFlag; }
- void Process()
- {
- m_pFSM->ClearAd0Folder();
- m_pFSM->RemoveDuplicateCenterSettingFiles();
- FSMEvent* fsmEvent = new FSMEvent(USER_EVT_CLEAR_UPLOADEDVIDEOFILES_FINISHED);
- int value(0);
- fsmEvent->param2 = m_pFSM->CleanVideoFiles(value, m_nInitFlag);
- fsmEvent->param1 = value;
- m_pFSM->PostEventFIFO(fsmEvent);
- }
- };
- struct OperateFileTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- OperateFileTask(ResourceWatcherFSM* pFSM,
- SpReqAnsContext<ResourceWatcherService_OperateFile_Req,
- ResourceWatcherService_OperateFile_Ans>::Pointer ctx)
- : m_pFSM(pFSM)
- , m_ctx(ctx)
- {
- }
- SpReqAnsContext<ResourceWatcherService_OperateFile_Req,
- ResourceWatcherService_OperateFile_Ans>::Pointer m_ctx;
- void Process()
- {
- FSMEvent* fsmEvent = new FSMEvent(USER_EVT_FILE_OPERAT_FINISHED);
- m_pFSM->ProcessFileOperation(m_ctx);
- m_pFSM->PostEventFIFO(fsmEvent);
- }
- };
- #if defined(RVC_OS_WIN)
- struct GetEventLogTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- GetEventLogTask(ResourceWatcherFSM* pFSM,
- SpReqAnsContext<ResourceWatcherService_ExtractEventLog_Req,
- ResourceWatcherService_ExtractEventLog_Ans>::Pointer ctx)
- : m_pFSM(pFSM)
- , m_ctx(ctx)
- {
- }
- SpReqAnsContext<ResourceWatcherService_ExtractEventLog_Req,
- ResourceWatcherService_ExtractEventLog_Ans>::Pointer m_ctx;
- void Process()
- {
- LOG_FUNCTION();
- FSMEvent* fsmEvent = new FSMEvent(USER_EVT_GET_EVENTLOG_FINISHED);
- m_pFSM->GetEventLog(m_ctx);
- fsmEvent->param1 = fsmEvent->param2 = 0;
- m_pFSM->PostEventFIFO(fsmEvent);
- }
- };
- #endif //RVC_OS_WIN
- class CardSwiperClient : public CardSwiperService_ClientBase
- {
- public:
- CardSwiperClient(CEntityBase* base) : CardSwiperService_ClientBase(base)
- {
- }
- };
|