#ifndef CHROMIUM_CMODTOOLS_H #define CHROMIUM_CMODTOOLS_H #define CHROMIUM_TIMER_ID 0xF001 #include #include #include "guitask/enum.h" #include #include using boost::serialization::singleton; #if (defined _WIN32 || defined _WIN64) #define CEFCLIENT_NAME "cefclient.exe" #else #define CEFCLIENT_NAME "cefclient" #endif namespace Chromium{ BETTER_ENUM(ERR_PAGE_REASON, int, CameraConfig, CardStoreIsBusy, MachineTypeError, TerminalManagerKickOut, TerminalManagerOff, breakdown, disabled, jobuncomplete, ErrNotify, normal) BETTER_ENUM(PAGE_TYPE, int, CameraConfig, TerminalManager, errPage, Ad, slv, init, TradeManager) BETTER_ENUM(TradeManageCodeEnum, int, Undefined, Trade, JobUncomplete, Disabled) BETTER_ENUM(TerminalManageCodeEnum, int, Off, On, KickOut) class CModTools : public singleton { private: CEntityBase* m_pEntity; public: void InitCModTools(CEntityBase* pEntity); std::pair StartChromiumBrowser(ERR_PAGE_REASON reason = ERR_PAGE_REASON::normal, std::tuple exParam = {"", "", "", 0, 0}); bool killAllChromium(); //通过taskkill 关闭掉所有的cefclient bool killChromiumByName(std::string name); void RestartProxyServer(); TradeManageCodeEnum CheckJobLimited(); private: std::pair ReadConfig(); //读本地配置,已废弃 std::tuple ReadCenterConfigStr(CSimpleStringA entityName = ""); std::pair getMainUrl(); std::pair getAdUrl(); std::pair getErrUrl(); std::string generateCefclientCmd(bool isExtend, std::string mainUrl); std::string generateAdCmd(std::string AdUrl); std::pair openCef(std::string cmdline, bool isGuard = false); void cefClientGuardian(std::string cmdline); void openAdPage(); std::pair GenerateErrPage(ERR_PAGE_REASON errType, std::tuple exParam); std::string GetSpShellBootTime(); bool isOutsidePad(); void setLimitReason(const char* reason); int StandardToStamp(const char* str_time, bool dateOnly); bool CheckTradeRecord(); private: CSimpleString m_strSite, m_strMachineType; }; template class TimerOutHelper : public ITimerListener { public: typedef void (T::*FuncTimer)(void *pUserdata); TimerOutHelper(T *p, FuncTimer pTimerFunc, void *pUserData, bool bDeleteSelf = false) : m_pObject(p), m_pUserData(pUserData), m_pTimer(pTimerFunc), m_bDeleteSelf(bDeleteSelf) {} virtual void OnTimeout(DWORD dwTimerID) { (m_pObject->*m_pTimer)(m_pUserData); if (m_bDeleteSelf) delete this; } private: void *m_pUserData; T *m_pObject; FuncTimer m_pTimer; bool m_bDeleteSelf; }; } #endif