123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737 |
- #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>
- #include <unordered_map>
- #if defined(RVC_OS_LINUX)
- #include <sys/sysinfo.h>
- #include <time.h>
- #include <sys/types.h>
- #include <dirent.h>
- #include <sys/stat.h>
- #else
- #include <ws2tcpip.h>
- #include <tchar.h>
- #include <WinCrypt.h>
- #include <atlbase.h>
- #include <conio.h>
- #include "mbnapi.h"
- #include <comdef.h>
- #endif //RVC_OS_LINUX
- using namespace std;
- #ifdef RVC_OS_LINUX
- #include "FileSimpleComp.h"
- #include "CommEntityUtil.hpp"
- #else
- #pragma comment(lib, "ws2_32.lib")
- #pragma comment(lib, "mbnapi_uuid.lib")
- #include "ResourceWatcher_UserCode.h"
- #include "FileSimpleComp.h"
- #include <time.h>
- #pragma comment(lib, "Gdi32.lib")
- #endif // RVC_OS_LINUX
- #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_RUN = EVT_USER + 1,
- 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
- };
- enum DealFileType
- {
- DFT_CenterSetting,
- DFT_Ad0
- };
- #ifdef RVC_OS_LINUX
- #else
- enum TestActionEnum
- {
- ACTION_NOTHINGTODO,
- ACTION_HANDSHAKE,
- ACTION_EXAMINE,
- ACTION_RESET,
- ACTION_CLOSE,
- ACTION_ENTITY_RESTART,
- ACTION_OS_RESTART,
- ACTION_POWER_RESTART,
- };
- #endif // RVC_OS_LINUX
- #include "ResourceWatcher_server_g.h"
- #include "ResourceWatcher_msg_g.h"
- using namespace ResourceWatcher;
- #ifdef RVC_OS_LINUX
- #define MAX_SOFTWARE_INSTALLED_DETECT_COUNT 50
- #endif // RVC_OS_LINUX
- #define MOD_VERSION "1.0.0.0"
- 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;
- }
- };
- #ifdef RVC_OS_LINUX
- //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 ProcCPUInfoStruct {
- unsigned int pid;
- char pname[1024];
- unsigned long utime; //user time
- unsigned long stime; //kernel time
- unsigned long cutime; //all user time
- unsigned long cstime; //all dead time
- }ProcCPUInfo;
- 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
- #else
- struct EntityCfgInfo
- {
- //int resetCount;
- int entityRestartCount;
- int osRestartCount;
- int powerRestartCount;
- bool bWaitRestart;
- map<ErrorCodeEnum, TestActionEnum> hsInfo;//handshake
- map<ErrorCodeEnum, TestActionEnum> examInfo;//examine
- map<ErrorCodeEnum, TestActionEnum> resetInfo;//reset
- map<ErrorCodeEnum, TestActionEnum> restartInfo;//restart
- };
- struct EntityRunInfo
- {
- bool bGetLoadOpt;
- bool bRestarting;
- int eState;
- int eTest;
- int loadOpt;
- int memoryHighCount;
- int cpuRatio;
- FILETIME prevSysKernel, prevSysUser;
- FILETIME prevProcKernel, prevProcUser;
- };
- struct CPUInforStruct {
- bool bInitialed;
- int level;
- CSimpleStringA csBrand;
- };
- #endif // RVC_OS_LINUX
- struct SystemBasicInfo
- {
- CSimpleStringA strManufacturer;
- CSimpleStringA strProductName;
- CSimpleStringA strSerialNumber;
- SystemBasicInfo():strManufacturer(true), strProductName(true), strSerialNumber(true) {}
- };
- const int DEFAULT_DAY_OF_BACKWARD = 90;
- class ResourceWatcherFSM : public FSMImpl<ResourceWatcherFSM>
- {
- public:
- #ifdef RVC_OS_LINUX
- ResourceWatcherFSM(void)
- :m_IsPadDevice(FALSE),
- m_csUploadVideoPath(true),
- m_nDayOfBackward(DEFAULT_DAY_OF_BACKWARD),
- m_bReadyFlag(false),
- m_bVideoClearReady(false),
- m_nMinSavedDay(DEFAULT_SAVE_DATE_COUNT),
- m_strTerminalNo(true),
- m_strDefaultDns(true),
- m_strBackupDns(true),
- m_nEnableSetDns(0),
- m_bFirstRunAfterBoot(FALSE),
- m_csDelFileSuffix(true),
- m_failDelCnt(0),
- m_cpuTop(0)
- {
- mAllVideoFileSizeCal = 0;
- mMaxFileSize = 0;
- mUiCalibration = 0;
- mUiRequireBytes = 0;
- mftAd0RemoveTime = 0;
- };
- #else
- ResourceWatcherFSM(void);
- #endif // RVC_OS_LINUX
- ~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 TriggerAtStatusChanged(bool bMStatus);
- 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);
- BOOL IsFirstRunAfterBoot() const
- {
- return m_bFirstRunAfterBoot;
- }
- #ifdef RVC_OS_LINUX
- void UploadMonitorSettings();
- bool GetMonitorInfo(CSimpleStringA& outInfo);
- void DetectSoftwareInstallStatus();
- #else
- void SetForceDiskCheckFlag(bool flag)
- {
- m_bNeedForceDiskCheck = flag;
- }
- #endif // RVC_OS_LINUX
- private:
- BOOL m_IsPadDevice;
- //Video Component
- CSimpleStringA m_csUploadVideoPath;
- 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 mszMaxSizeFilePath[MAX_PATH];
- typedef map<UINT, UINT>::const_iterator const_map_cu_iter;
- DiskInfo diskInfo;
- bool m_bVideoClearReady;
- int m_nMinSavedDay;
- int m_cpuTop; // CPU资源消耗最高的top进程个数
- CSystemStaticInfo m_RvcSysinfo;
- typedef std::string bs_key;
- typedef DWORD bs_value;
- typedef map<bs_key, bs_value> BlackSheet;
- typedef BlackSheet::const_iterator const_bs_iter;
- typedef BlackSheet::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;
- BOOL m_bFirstRunAfterBoot;
- #ifdef RVC_OS_LINUX
- time_t mftAd0RemoveTime;
- unsigned long long mAllVideoFileSizeCal;
- unsigned long long mMaxFileSize;
- unsigned long long mUiCalibration;
- unsigned long long mUiRequireBytes;
- int m_diskLastWarnHour;
- #else
- FILETIME mftAd0RemoveTime;
- ULARGE_INTEGER mAllVideoFileSizeCal;
- ULARGE_INTEGER mMaxFileSize;
- ULARGE_INTEGER mUiCalibration;
- ULARGE_INTEGER mUiRequireBytes;
- bool m_DoneDetectAutostart;
- //1:将VBS改成EXE,前提是VBS必须已在注册表
- //2:设置使用EXE自启动
- //3:不设置开机自启动(通过注册表)
- int m_forceStartupWithExeFlag;
- bool m_bIsVerified;
- vector<CSimpleStringA>m_nonSignedFiles;
- int m_iNonSignedTotal;
- map<CSimpleStringA, EntityCfgInfo> m_entCfgInfo;
- map<CSimpleStringA, EntityRunInfo> m_entRunInfo;
- vector<CSimpleStringA> m_activeEntity, m_allEntity, m_vKeyEntity, m_vQueryStateEntity;
- int m_restartNormal, m_restartSpecial, m_maxOsRestart, m_maxPowerRestart, m_warmLevel, m_diskLastWarnHour;
- DWORD m_dwIssueCount, m_dwCaptureCount;
- bool m_bInIssue, m_bFirstCalcCpu, m_bEverInMainPage, m_bHaveGetEntityList, m_bFWBEntityAdd;
- bool m_bNeedForceDiskCheck;
- int m_simulateTest;
- CSimpleStringA m_csKeyEntity;
- __int64 m_xIdlePre, m_xKernelPre, m_xUserPre;
- #endif // RVC_OS_LINUX
- int m_iVerify;
- int m_iNonSignedDisplay;
- int m_cpuHighPercent, m_memHighPercent, m_diskHighPercent;
- FILE_LAYOUT_ENTRY m_FileEntry;
- BOOL checkActiveBefore;
- BOOL firstMpage;
- public:
- int CleanVideoFiles(int& newDeletedFilesNum, int initFlag = 1);
- void CheckDiskFileSpace();
- #ifdef RVC_OS_LINUX
- 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);
- void AppendVideoSizeTogether();
- void CalculateFreeDiskNeeded();
- void RecordFreeDiskNeededToRunCfg();
- void GetFreeDiskNeededFromRunCfg();
- int RemoveExpireVideoFileAndRecord(LPCTSTR dirName, int& deletedFileCnt, int& deleteFailedCnt, const int nFlag);
- #else
- void CalculateBackTime(PFILETIME ftResultTime, int days);
- BOOL CalCulateUploadFileAddition(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);
- }
- int ProcessVideoFile(LPCTSTR dirName, int& deletedFileCnt, int& deleteFailedCnt, const int nFlag);
- // End Video Component
- int ProcessFileSpaceCalculation(LPCTSTR lpszPath, PULARGE_INTEGER puliSpaceBytes);
- // Add -Josephus@2017713 16:04:18
- #endif // RVC_OS_LINUX
- 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);
- void GetSystemCPUStatus();
- void GetSystemMemoryStatus();
- void GetSystemDiskStatus();
- void HardwareInfoTimer(void* pData);
- void DiskCheckTimer(void* pData);
- void LinkDetect(int detectType, const char* url, bool& status, unsigned int& delay, int warnFlag = 1);
- #if defined(RVC_OS_WIN)
- int GetCpuUsageRatio(int pid);
- ULONGLONG GetDiskUsedByte();
- #endif // RVC_OS_WIN
- int ClearSpecifieFile(DealFileType fileType, LPCTSTR dirName, int& deletedFileCnt, int& deleteFailedCnt);
- // Start Video Component2 --Josephus at 16:19:56 201755
- void ClearVideoQueue();
- #ifdef RVC_OS_LINUX
- // Start CenterSetting Clear Job --Josephus at 15:57:58 20161210
- BOOL RemoveDuplicateCenterSettingFiles();
- int RemoveSpecifiedFile(DealFileType fileType, LPCTSTR szFilePath, LPCTSTR szFileName);
- // End CenterSetting clear Job
- // Has been purified --Josephus at 10:42:55 201759
- void PrintVideEmurateResult();
- #else
- // Start CenterSetting Clear Job --Josephus at 15:57:58 20161210
- int DoSomethingWith(DealFileType fileType, LPCTSTR szFilePath, LPCTSTR szFileName);
- // End CenterSetting clear Job
-
- void CalCulateFileInfo(LPCTSTR lpFilePath, PWIN32_FIND_DATA pWfdata);
- // Has been purified --Josephus at 10:42:55 201759
- void PrintResult()
- {
- char szResult[DEFAULT_OUTPUT_FORMAT_SIZE];
- ByteSprintf(szResult, (double)mMaxFileSize.QuadPart);
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Max Video file: %s size: %s", mszMaxSizeFilePath, szResult);
- ByteSprintf(szResult, (double)mAllVideoFileSizeCal.QuadPart);
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Totally(size()#%d) directory size: %s", m_VideoFiles.size(), szResult);
- }
- #endif // RVC_OS_LINUX
- void ClearMoreVideoFiles();
- bool IsNeedToFirstClear();
- void SetSysValAndBroadcast(DWORD dwVal, LPCTSTR lpszMessage);
- // End --Josephus at 16:20:02 201755
- void CenterSettingDelete();
- void AutoDeleteFiles();
- BOOL DeleteVersionPackage();
- int ProcessFileDelete(LPCTSTR lpszPath, int& nDelSucCnt, int& nDelFailedCnt, bool delDir = false);
- // Add Ad0 folder job [4/2/2018 10:53 @Gifur]
- BOOL ClearAd0Folder();
- BOOL IsTodayDone(int nRecordTime);
- BOOL GetSystemBootTime(CSmallDateTime& systemBootTime);
- BOOL DetectIsFirstRunAtBoot();
- #ifdef RVC_OS_LINUX
- /** 返回操作系统当前的版本,比如1032,1010,1031*/
- UINT GetSystemDisplayVersion(CSimpleStringA& strVersion);
- void UploadSysVersionInfo(UINT& ver);
- string MemoryProcessStatus();
- long GetCPURunTime(CPUInfo* cpu);
- long ReadProcCPURunTime(DWORD pid, ProcCPUInfo* pInfo);
- const char* GetItems(const char* buffer, unsigned int item);
- void GetOperationDiskStatus();
- void GetDiskStatusFrom(LPCTSTR path);
- void ConfirmWindowEffectHasBeenOpen();
- void switchWindowsEffect(const char* cfgFilePath, bool enable);
- /** 1032操作系统版本出现剪贴板和操作中心,需要将剪贴板关掉避免手势唤起
- * 统信的人告知可以通过删除剪贴板程序实现……JUST DO IT!
- */
- void ConfirmDDEClipboardDisable();
- void RecoverDDEClipboardEnable();
- /** 自己摸索,统信说需要操作系统定制方能解决 [Gifur@202198]*/
- void ConfirmNotificationCenterDisable();
- #else
- BOOL ClearDirRecursiveEx(LPCSTR lpDirPat);
- bool CopyExeToRoot(const CSimpleStringA& csVersion);
- bool RegOperation();
- bool RegRdVtmVersion(CSimpleStringA& VTMpath, CSimpleStringA& vtmVersion);
- bool RegWtVtmPath();
- bool RegWtVtmVersion();
- void CreateLink(const CSimpleStringA& exePath, const CSimpleStringA& csVersion);
- bool CreateLinkFile(const CSimpleStringA& szStartAppPath, const CSimpleStringA& szAddCmdLine,
- const CSimpleStringA& szDestLnkPath, const CSimpleStringA& szIconPath);
- bool GetVtmVersionFromActiveTxt(CSimpleStringA& csVersion);
- bool UpdateExe();
- bool GetRegValue(HKEY hKey, LPCTSTR lpcszParam, CHAR* pSzValue, DWORD* pDwSizeOfSz);
- void DetectAutoStartupCover();
- //0:explorer.exe
- //1:vbs
- //2:vtm.exe
- //-1:failed
- //-2:do before in day
- void DetectAutoStartup(int& vbsType);
- ErrorCodeEnum ChangeAutoStartupWithExe(bool resetExplorer = false);
- void InitialAutoStartupSetType();
- BOOL IsHasSetAutoStartupByFolder();
- void DetectVersionHasChangedAndWarn();
- void DetectDestopFileAndWarn();
- ErrorCodeEnum DetectVTMInstalledBySetup(BOOL& fYes);
- void DetectVersionHasChangedAndWarnCover()
- {
- if (!checkActiveBefore) {
- DetectVersionHasChangedAndWarn();
- checkActiveBefore = TRUE;
- }
- }
- void VerifySignature();
- void VerifySignature(const CSimpleStringA& filePath);
- CSimpleStringA GetFileName(const CSimpleStringA& filePath);
- bool RetrieveDigitalSignatureInfo(const char* pFilePath);
- bool VerifyFirstCertificate(HCERTSTORE hStore, PCMSG_SIGNER_INFO pSignerInfo);
- bool VerifyOtherCertificate(PCMSG_SIGNER_INFO pSignerInfo);
- int IsWifiConnected();
- #endif // RVC_OS_LINUX
- void AlarmSystemBasicInfo();
- ErrorCodeEnum CatchSystemBasicInfo(SystemBasicInfo& info);
- void readVideoStorePath();
- };
- class RunEvent : public FSMEvent
- {
- public:
- RunEvent() : FSMEvent(USER_EVT_RUN) {}
- virtual ~RunEvent() {}
- };
- 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->ClearMoreVideoFiles();
- m_pFSM->PostEventFIFO(fsmEvent);
- }
- };
- struct AutoDeleteFilesTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- AutoDeleteFilesTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
- void Process()
- {
- m_pFSM->AutoDeleteFiles();
- }
- };
- #ifdef RVC_OS_LINUX
- struct UploadMonitorInfoTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- UploadMonitorInfoTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
- void Process()
- {
- m_pFSM->UploadMonitorSettings();
- }
- };
- struct DetectSoftwareInstallStatusTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- DetectSoftwareInstallStatusTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
- void Process()
- {
- m_pFSM->DetectSoftwareInstallStatus();
- }
- };
- 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);
- }
- };
- #else
- struct CreateLinkTask :public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- CreateLinkTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
- void Process()
- {
- m_pFSM->RegOperation();
- }
- };
- struct VerifyDigitSignTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- VerifyDigitSignTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
- void Process()
- {
- m_pFSM->VerifySignature();
- }
- };
- #endif // RVC_OS_LINUX
- struct CenterSettingDeleteTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- CenterSettingDeleteTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
- void Process()
- {
- m_pFSM->CenterSettingDelete();
- }
- };
- struct CheckDiskFileSpaceTask : public ITaskSp
- {
- ResourceWatcherFSM* m_pFSM;
- CheckDiskFileSpaceTask(ResourceWatcherFSM* pFSM) : m_pFSM(pFSM) {}
- void Process()
- {
- m_pFSM->CheckDiskFileSpace();
- }
- };
- 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();
- }
- };
|